Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injectable HttpClient for the HttpClientFactory pattern #37

Closed
kuru-rin opened this issue Jun 18, 2022 · 3 comments
Closed

Injectable HttpClient for the HttpClientFactory pattern #37

kuru-rin opened this issue Jun 18, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@kuru-rin
Copy link

kuru-rin commented Jun 18, 2022

It is currently not possible to inject my own HttpClient using IoC.

Also then instead of the Endpoint property in the client config, using the HttpClientFactory pattern one could do this as well:

services.AddHttpClient<IJikan, Jikan>(client => {
  client.Timeout = TimeSpan.FromSeconds(10);
  client.BaseAddress = new Uri(/* your endpoint */)
});

See this page for even more benefits: https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests

@Ervie
Copy link
Owner

Ervie commented Jun 19, 2022

I'll have a look at this and #36 in the following days, when I find some free time.

@Ervie Ervie self-assigned this Jun 19, 2022
@Ervie Ervie added the enhancement New feature or request label Jun 19, 2022
@Ervie
Copy link
Owner

Ervie commented Jun 24, 2022

I pushed version 2.2.0, that allows injecting own HttpClient and use it with DI.
I'll keep Endpoint in the configuration until version 2.3.0 - it will be just marked as obsolete.

@kuru-rin
Copy link
Author

Very nice. Thanks for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants