I am working on a Asp.net web api project. I recently created an end point for documentation using config.Services.GetApiExplorer();
What is the best way to hide this endpoint in production and still make it available for all other developers in my team.
One way I could think of is to register a route using
#if debug
routes.MapRoute(
"documentation",
"documentation/help",
new { controller = "apiexplorer", action
= "Index" }
);
#endif
There is two attribute could hide an API endpoint:
But for your case, I probably create a new attribute to check the environment and apply that attribute to your controller method. Inject the 'IHostingEnvironment' class, then use .IsDevelopment() method.