Create nuget package from a REST API Web application

1

I have a web service API REST in ASP.NET CORE 2.0 several projects (layers) in it. However, for larger forces, it can not be used as a service.

It was then suggested to create a nuget package for this WEB API. I've never created a nuget package and I've seen examples on the internet of simple projects being used as a nuget package and not a WEB REST API. The question is:

Can I generate a nuget package from my WEB API REST application?

-

** Edit

-

Force Majeure = > The fearful stackeholders

Application Type = > Audit log (for various other applications)

Situation

Applications will not be able to do anything without logging in before, and stackeholders are concerned that this API will eventually stop working for some reason, and all applications consuming this service will stop working.

>

-

Application Architecture

  • Controller
  • Application
  • Domain
  • Repository
  • etc ...

1st) Do I need to change Architecture?

2nd) If it is possible to use this API as a nuget package, would I use it as if it were a service? For example I have the GET route: link . Would I use these Controllers routes? Or would I access the API's resources in another way?

  • Here is the repository for this project: link
asked by anonymous 10.01.2018 / 21:59

1 answer

1

Yes, nothing prevents you from implementing a NuGet package that, when invoked, prepares endpoints WebAPI.

This scenario can be useful when you are developing a web application compatible with endpoints .

This is the case for example from the following library:

link

Note that one of the modules ( link ) is intended to offer features such as < in> endpoints WebAPI.

Incidentally this module is also available as a NuGet package:

link

Answering your questions:

  

1st) Do I need to change Architecture?

No. It can be maintained in the same way. The only thing you need to ensure is that the API controllers of the NuGet package are loaded and made available in the same way.

  

2nd) If it is possible to use this API as a nuget package, would I use it as if it were a service? For example I have the GET route: link . Would I use these Controllers routes? Or would I access the API's resources in another way?

Yes. The only difference between the controllers in your application and those in the NuGet package (s) is the assembly where they are located.

When you incorporate a package into your application, what you are actually doing is performing the download of a set of assemblies that will be referenced by your project. p>

When you run your web application it will be available under a URL where all the endpoints will be served - both those of your application and those present in referenced assemblies .

So you can continue to use local relative URLs to access the endpoints (% with%, for example.)

    
10.01.2018 / 22:13