You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
using LINGYUN.ApiGateway.Utils;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Ocelot.LoadBalancer.LoadBalancers;
|
|
using Ocelot.Multiplexer;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Dtos;
|
|
|
|
namespace LINGYUN.ApiGateway.Controllers
|
|
{
|
|
[RemoteService(Name = ApiGatewayConsts.RemoteServiceName)]
|
|
[Area("ApiGateway")]
|
|
[Route("api/ApiGateway/Basic")]
|
|
public class ApiGatewayController : Controller
|
|
{
|
|
protected IServiceProvider ServiceProvider { get; }
|
|
protected ILoadBalancerFinder LoadBalancerFinder { get; }
|
|
public ApiGatewayController(
|
|
IServiceProvider serviceProvider,
|
|
ILoadBalancerFinder loadBalancerFinder)
|
|
{
|
|
ServiceProvider = serviceProvider;
|
|
LoadBalancerFinder = loadBalancerFinder;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("Aggregators")]
|
|
public Task<JsonResult> GetAggregatorsAsync()
|
|
{
|
|
var aggregators = ServiceProvider.GetServices<IDefinedAggregator>();
|
|
|
|
var aggregatorDtos = new ListResultDto<string>(aggregators.Select(agg => agg.GetType().Name).ToList());
|
|
|
|
return Task.FromResult(Json(aggregatorDtos));
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("LoadBalancers")]
|
|
public async Task<JsonResult> GetLoadBalancersAsync()
|
|
{
|
|
var loadBalancers = await LoadBalancerFinder.GetLoadBalancersAsync();
|
|
|
|
var loadBalancerDtos = new ListResultDto<LoadBalancerDescriptor>(loadBalancers);
|
|
|
|
return Json(loadBalancerDtos);
|
|
}
|
|
}
|
|
}
|
|
|