At the moment I am creating many small APIs at work. Many of these projects share some of the basic logic of controllers. Is there a way to add them to the nuget package and use them during startup?
For example. e.g. adding mvc:
IApplicationBuilder app;
....
app.UseMvc;
app.UseBasicApiVersionController();
The idea is that we have a version endpoint in all of our microservices.
For example:
http: // url / version
return {"version": "1.0.0"}
How can I do this in the nuget package?
So all developers only need to add one line of code to add this endpoint to their microservice? We use the dotnet core.
Do not help create the nuget package yourself.
My guess for a start is something like this:
public static IApplicationBuilder UseBasicApiVersionController(this IApplicationBuilder app)
{
if (app == null)
throw new ArgumentNullException("app");
.....
return app;
}
* Edit:
If you add a controller to the nuget package project, it will be automatically detected. But this is not the functionality that I want. I can have 10 services that need this controller. Having 1-2 services that only want a different versioning logic. For example. The client application must not have an endpoint "/ version".
That is why during startup I want to use app.UseBasicApiVersionController ();
source
share