55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using AS1024.CommunityDocumentationPage.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using AS1024.CommunityDocumentationPage.Interfaces;
|
|
|
|
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, IBgpCommunityDocumentation documentation)
|
|
{
|
|
_logger = logger;
|
|
Configuration = configuration;
|
|
_documentation = documentation;
|
|
}
|
|
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
var results = await _documentation.GetBgpCommunities();
|
|
var filtered = results.Results.Where(b => b.Name.StartsWith(Configuration["ASN"]))
|
|
.ToList();
|
|
|
|
return View(filtered);
|
|
}
|
|
|
|
[NonAction]
|
|
protected Uri BuildNetBoxURI()
|
|
{
|
|
var endUrl = new UriBuilder();
|
|
|
|
endUrl.Path = "/api/ipam/route-targets";
|
|
endUrl.Host = Configuration["NetBoxHost"];
|
|
endUrl.Scheme = "https";
|
|
|
|
return endUrl.Uri;
|
|
}
|
|
|
|
public IActionResult Privacy()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|
|
} |