Baby steps on code refactoring
This commit is contained in:
@@ -4,26 +4,29 @@ using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
using AS1024.CommunityDocumentationPage.Interfaces;
|
||||
using AS1024.CommunityDocumentationPage.DIScopes;
|
||||
|
||||
namespace AS1024.CommunityDocumentationPage.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IBgpCommunityDocumentation _documentation;
|
||||
|
||||
private IConfiguration Configuration { get; }
|
||||
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IConfiguration configuration)
|
||||
IConfiguration configuration, IBgpCommunityDocumentation documentation)
|
||||
{
|
||||
_logger = logger;
|
||||
Configuration = configuration;
|
||||
_documentation = documentation;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> IndexAsync()
|
||||
{
|
||||
var results = await ReadAPI(Configuration["APIKey"]);
|
||||
|
||||
var results = await _documentation.GetBgpCommunities();
|
||||
var filtered = results.Results.Where(b => b.Name.StartsWith(Configuration["ASN"]))
|
||||
.ToList();
|
||||
|
||||
@@ -39,7 +42,7 @@ namespace AS1024.CommunityDocumentationPage.Controllers
|
||||
client.DefaultRequestHeaders.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", token);
|
||||
var result = await client.GetAsync(BuildNetBoxURI());
|
||||
var result = await client.GetAsync(BuildNetBoxURI().AbsoluteUri);
|
||||
var stringResult = await result.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<RouteTargets>(stringResult);
|
||||
} catch
|
||||
|
||||
Reference in New Issue
Block a user