Closed andysleigh closed 6 years ago
Yep, this is something we should fix. Thanks.
@andysleigh - are you trying to bind to the root url or to all URLs?.
For instance Map("", ...)
will handle all URLs. Map handles all URLs that are suffixes of what you put in.
@rynowak - Yes I was trying to use bind to the root URL. I can now see I'll need to use MapWhen to do this. Thanks.
app.MapWhen(c => c.Request.Path == "/", b => b.UseMiddleware<HealthCheckMiddleware>());
Currently if I try to set up a health check on the root path by calling
UseHealthCheck("")
then it throws an ArgumentException with the message "A URL path must be provided". Directly mapping the HealthCheckMiddleware to the root path using the code below works fine:app.Map("", b => b.UseMiddleware<HealthCheckMiddleware>());
I can't see any good reason to enforce this in UseHealthCheck so can we remove the path check from HealthCheckApplicationBuilderExtensions.cs please? At my work we write a lot of web APIs with ASP.NET Core and tend to put a a health check on the root (currently with our own HealthCheckMiddleware class).