52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using System.Text;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using Microsoft.Extensions.Hosting;
|
|
using ShellyExporter;
|
|
using System.Xml.Linq;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
if (!builder.Environment.IsDevelopment())
|
|
{
|
|
builder.WebHost.UseKestrel();
|
|
builder.WebHost.UseUrls(builder.Configuration["Kst:Url"]);
|
|
}
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
app.MapControllers();
|
|
|
|
app.Map("/metrics", () =>
|
|
{
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var host in builder.Configuration.GetSection("Hosts").GetChildren())
|
|
{
|
|
sb.Append(Metrics.Get($"http://{host.Value}/status", host.Path.Replace("Hosts:", "")).Result);
|
|
}
|
|
|
|
return sb.ToString();
|
|
});
|
|
|
|
|
|
|
|
|
|
app.Run();
|