I want to add an Ocelot Gateway healthcheck, but
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
builder.Configuration.AddOcelot(builder.Environment);
var app = builder.Build();
app.UseOcelot();
app.MapHealthChecks("/_health", new HealthCheckOptions
{
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.Run();
Anyone any clue on how to do this?
Solved thanks to Artur in comments above.
Just add UseRouting()
, MapHealthChecks()
and UseEndpoints()
BEFORE the UseOcelot()
method.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
builder.Configuration.AddOcelot(builder.Environment);
var app = builder.Build();
app.UseRouting();
app.MapHealthChecks("/_health", new HealthCheckOptions
{
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseEndpoints(e =>
{
e.MapControllers();
});
app.UseOcelot();
app.Run();