0

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?

sandreas
  • 101
  • 1
  • 7
  • 1
    This is classical use of dependency injection, and inversion of control. For example, check this article - https://brettedotnet.wordpress.com/2014/07/16/web-api-and-interface-parameters/. – kosist Sep 28 '20 at 14:23
  • @kosist That could solve a problem, but in this case, the supported endpoint controlers do not exist. You would need to implement your own middleware logic to address the requested custom plugged in endpoints. – Silvermind Sep 28 '20 at 14:29

0 Answers0