https://github.com/michaco/autorestwithhttpclientfactory
Trying to integrate autorest clients with HttpClientFactory
https://github.com/michaco/autorestwithhttpclientfactory
Last synced: 9 months ago
JSON representation
Trying to integrate autorest clients with HttpClientFactory
- Host: GitHub
- URL: https://github.com/michaco/autorestwithhttpclientfactory
- Owner: MichaCo
- Created: 2018-05-14T08:14:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-14T21:37:15.000Z (about 8 years ago)
- Last Synced: 2025-08-18T16:29:12.932Z (10 months ago)
- Language: C#
- Homepage: http://michaco.net/blog/IntegratingAutorestWithHttpClientFactoryAndDI
- Size: 21.5 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Testing Autorest with HttpClientFactory
See http://michaco.net/blog/IntegratingAutorestWithHttpClientFactoryAndDI
In this solution I'm trying to integrate `IHttpClientFactory` from `Microsoft.Extensions.Http` with auto generated autorest clients.
### Main problems are:
* Initialization of the generated client:
The generated client doesn't come with overloads which accept an `HttpClient` (only protected ctor)
* In addition, we have to pass in the base uri and probably credentials
### Possible Solutions:
* Create a custom partial client class for a custom ctor to set the `HttpClient`
* Change autorest runtime library to work with `IHttpClientFactory` => bigger change and potentially too many dependencies added
* Change `IHttpClientFactory` to expose/create `HttpClientHandler`s => would be the optiomal solution.