build: bootstrap solution and quality gates (#3)
quality-gate / quality (push) Successful in 58s
quality-gate / quality (push) Successful in 58s
Closes #3
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Net;
|
||||
using FinalFactory.Rendezvous.Server.Transport;
|
||||
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services
|
||||
.AddOptions<UdpMediatorOptions>()
|
||||
.BindConfiguration(UdpMediatorOptions.SectionName)
|
||||
.ValidateDataAnnotations()
|
||||
.Validate(
|
||||
options => IPAddress.TryParse(options.ListenAddress, out _),
|
||||
$"{UdpMediatorOptions.SectionName}:ListenAddress must be an IP address.")
|
||||
.ValidateOnStart();
|
||||
builder.Services.AddSingleton<UdpMediatorService>();
|
||||
builder.Services.AddHostedService(static services => services.GetRequiredService<UdpMediatorService>());
|
||||
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
app.MapGet("/health/live", static () => Results.Ok(new { status = "live" }));
|
||||
app.MapGet(
|
||||
"/health/ready",
|
||||
static (UdpMediatorService mediator) => mediator.LocalEndpoint is null
|
||||
? Results.StatusCode(StatusCodes.Status503ServiceUnavailable)
|
||||
: Results.Ok(new { status = "ready" }));
|
||||
|
||||
await app.RunAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Entry point marker used by integration-test hosts.
|
||||
/// </summary>
|
||||
public partial class Program;
|
||||
Reference in New Issue
Block a user