Make the code cleaner to read
This commit is contained in:
parent
dd643ab8ab
commit
1f3778095c
|
|
@ -31,7 +31,7 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||
|
||||
public async Task<List<IPGeoFeed>> GetGeoFeedData()
|
||||
{
|
||||
List<IPGeoFeed> geoFeed = new List<IPGeoFeed>();
|
||||
List<IPGeoFeed> geoFeed = [];
|
||||
using HttpClient client = httpClientFactory.CreateClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", configuration["APIKey"]);
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
|
@ -46,10 +46,13 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||
logger.LogDebug($"Making request to {uri}...");
|
||||
|
||||
using HttpResponseMessage result = await client.GetAsync(uri);
|
||||
if (result.IsSuccessStatusCode)
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
break;
|
||||
}
|
||||
string stringResult = await result.Content.ReadAsStringAsync();
|
||||
jsonData = JsonSerializer.Deserialize<NetboxData>(stringResult, new JsonSerializerOptions {
|
||||
jsonData = JsonSerializer.Deserialize<NetboxData>(stringResult, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
|
||||
});
|
||||
|
||||
|
|
@ -83,7 +86,6 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||
uri = new Uri(jsonData.Next);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue