Quantcast
Viewing all articles
Browse latest Browse all 3655

.Net web application with different api clients

I have a Blazor project and I need to consume several REST APIs. All of those APIs require different configuration. For example: For one of those APIs I have to bypass certificate by using ServicePointManager.ServerCertificateValidationCallback. And for another API I have to send GET request with bodypayload (which is not semantic). For another API I need JWT... and so forth.The point is that I have different HttpClient(s) and they require different configurations.

So the question is how do you deal with it? You have all these amazing things in .NET like dependency injection, singleton, transient, IHttpClientFactory and you can configure your API client in startup.cs or in ctor or in any other place for that matter. So what is the right approach here?

I have a strong filling that something like strategy design pattern can be useful in this case


Viewing all articles
Browse latest Browse all 3655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>