aspnet / Diagnostics

[Archived] Diagnostics middleware for reporting info and handling exceptions and errors in ASP.NET Core, and diagnosing Entity Framework Core migrations errors. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
213 stars 111 forks source link

Multiple health check endpoints #512

Closed steveoh closed 5 years ago

steveoh commented 5 years ago

In preview 2 I was able to use

      app.UseHealthChecks("/health");
      app.UseHealthChecks("/health/detail", new HealthCheckOptions()
            {
                // This custom writer formats the detailed status as JSON.
                ResponseWriter = WriteResponse,
            });

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Go to /health to see the health status");
            });

And that would work properly.

In preview 3 both routes return the default data and the response writer is ignored. You can test this in the CustomWriterStartup.cs file by adding the code above.

What is the proper way to expose more than one health check endpoint? Tags?

rynowak commented 5 years ago

I think your issue is the same as https://github.com/aspnet/Diagnostics/issues/511- this is using the .Map middleware primitive, so if these middleware were ordered in the opposite way, it would work as you expect.

I agree that this is surprising and bad, I think we will have change how this is implemented.

steveoh commented 5 years ago

Yes I believe this is a duplicate. I will close this and follow that one.

rynowak commented 5 years ago

Fixed for the 2.2.0 release. Thanks for the feedback 👍