简体   繁体   English

我如何使用C#在ASP.NET Web API(非.NET Core)中实现API网关

[英]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 现在,我们使用asp.net Web api(不是.net核心)开发了许多服务,我们需要开发一种网关,以使客户端连接到一个端点,此网关决定调用哪个api来处理传入的请求,然后返回响应给客户端,因此作为网关的Web api将重新路由请求并返回响应

client <----> api gateway <----> appropriate web api 客户端<----> api网关<---->适当的Web api

We need to develop it simple as possible ,but with best practise using c# and asp.net web api 我们需要尽可能简单地开发它,但是要使用c#和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 . Ocelot是一个功能强大的库,但是它在.Net Core中使用,它可以帮助我们构建弹性网关,并且不确定在这种情况下可以使用的类似Asp.net库。 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. 如果找不到合适的库或提供程序(云API网关提供程序,如azure,AWS),并且必须编写自己的网关api,那么您必须了解一些事情。

Best practices for api gateway. API网关的最佳做法。

Api gateway is very useful but at the same time it can be bottle neck. Api网关非常有用,但同时也可能成为瓶颈。 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. 根据您的请求负载,您可能必须实现“ Circuit breaker”,“ Retry”和“ bulk head”之类的模式,为此,您可以使用称为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/App-vNext/Polly

https://github.com/reactiveui/refit https://github.com/reactiveui/refit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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