简体   繁体   中英

how can i implement api gateway in asp.net web api (not .net core) using c#

Now, we developed many services using asp.net web api (not .net core) we need to develop a gate-way to let the client connect to one end point after that this gateway decide which api to call to process the incoming request and return the response to the client , so web api as a gateway will reroute the request and return the response

client <----> api gateway <----> appropriate web api

We need to develop it simple as possible ,but with best practise using c# and asp.net web api

any ideas ??

Ocelot is powerful library but that is used in.Net Core which helps us build resilient gateway and am not sure of similar Asp.net libraries that you can use in this case . If you are unable to find the suitable library or provider (cloud api gateway providers like azure , AWS ) and you have to write your own gateway api then you have to be aware of few things.

Best practices for api gateway.

Api gateway is very useful but at the same time it can be bottle neck. Your gateway should be resilient and highly available. Depending on your request load you may have to implement patterns like "Circuit breaker" , "Retry" and "bulk head" and for that you can use library called Polly. You can log your requests for debugging and performance monitoring. Security is another aspect but really depends how you implement authentication. You may use combination of following libraries to achieve your goal.

https://github.com/App-vNext/Polly

https://github.com/reactiveui/refit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM