Creating a more complex endpoint
In this section, we will create a more complex endpoint, step by step. Let's do this by writing a really simple health check endpoint, similar to what you might need if you were to run your application inside a Kubernetes cluster, or just to tell others about your health status:
- Microsoft advices starting with the definition of the API to add the endpoint from the developer's point of view. We do the same here. This means that we will add a
MapSomething
method first, without an actual implementation. This will be an extension method on theIEndpointRouteBuilder
object. We are going to call itMapMyHealthChecks
:// the new endpoint app.MapMyHealthChecks("/myhealth"); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
The new endpoint should be added...