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, as you might need if you were to run your application inside a Kubernetes cluster, or just to tell others about your health status:
- Microsoft proposes starting with the definition of the API to add the endpoint from the developer 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 onIEndpointRouteBuilder
. We are going to call itMapMyHealthChecks
:// the new endpoint endpoints.MapMyHealthChecks("/myhealth"); Â Â endpoints.MapControllerRoute( Â Â Â Â name: "default", Â Â Â Â pattern: Â Â Â Â Â Â Â Â "{controller=Home}/{action=Index}/{id?}");
The new endpoint should be added in the same way as the prebuilt...