dotnet core / C# WebAPI - Controllers as Plugins

329 views Asked by At

Pretty often i have to implement a little web api as "proxy" for different customers using specific api requests to other APIs (either for simplification or authentication, etc.)... here is a simplyfied example:

    https://myproxy.intranet/api/weather => https://www.weatherapi.com/api/today
    https://myproxy.intranet/api/time => https://www.timeapi.com/api/now
    https://myproxy.intranet/api/currentcy => https://www.currency.com/api/dollar

In most cases, the APIs and their endpoints are similar if not identical, so much of the code could be reused. At the moment i created some nuget libraries to solve this, but the problem is, that i always have to create a WebApi project including full dev ops etc. and implement the controllers with pretty much the same code using my libs.

My idea would be to have one WebAPI project (e.g. MyAwesomeProxy), which uses Plugins to extend the available API endpoints, that are available, e.g.:

    MyAwesomeProxy => basic functions like authentication, etc.
    MyAwesomeProxy/plugins/Controllers/weather.dll => proxy for the weather api is available
    MyAwesomeProxy/plugins/Controllers/time.dll => proxy for the time api is available
    ...

So basically what i would like have is an extendable WebApi-Project - just put the main project to IIS, the dlls you need into a directory and the api works like expected.

Important Note: Since some of the APIs are customer specific, i can't implement a monolith and just enabling and disabling the available endpoints via license or settings - i would like to prevent decompiling and information leaks.

How would i do that? Is that even possible?

0

There are 0 answers