Skip to content
Trying to integrate autorest clients with HttpClientFactory
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitattributes
.gitignore
AutorestWithHttpClientFactory.sln
Readme.md

Readme.md

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 HttpClientHandlers => would be the optiomal solution.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.