51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using IM.InitCommon.Management;
|
|
|
|
using ConnectorService.Hubs;
|
|
using ConnectorService.Services;
|
|
using IM.InitCommon;
|
|
|
|
namespace ConnectorService
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.ConfigureDbConfiguration();
|
|
|
|
builder.Services.AddSignalR();
|
|
builder.Services.AddSingleton<ConnectionRegistry>();
|
|
builder.Services.AddHostedService(sp => sp.GetRequiredService<ConnectionRegistry>());
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
builder.ConfigExtraServices();
|
|
|
|
var app = builder.Build();
|
|
if (app.ApplyMigrationsIfRequested(args)) return;
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseAppDefault();
|
|
app.MapManagementHealth();
|
|
|
|
|
|
app.MapHub<ChatHub>("/chat");
|
|
app.MapGet("/internal/management/connections", async (ConnectionRegistry registry) => await registry.Counts());
|
|
app.MapPost("/internal/management/disconnect/{id:guid}", async (Guid id, ConnectionRegistry registry) => { await registry.Disconnect(id); return new { disconnected = true }; });
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|