Genbox / SimpleS3

A .NET Core implementation of Amazon's S3 API with focus on simplicity, security and performance
MIT License
50 stars 8 forks source link

Configuring HttpClient outside SimpleS3 #44

Closed LordMike closed 3 years ago

LordMike commented 3 years ago

Describe the feature One of the benefits of IHttpClientFactory is that the user (me) can configure a HttpClient that some library can use, through DI, without that library having to accept a HttpClient from myself. It seems that SimpleS3 does not use a named client, meaning the user can only configure the HttpClients used, by configuring the default HttpClient provided by the factory.

If two libraries were to do this, it wouldn't be possible to customize the options for just one of them.

Allow an optional name to be provided when using the UseHttpClientFactory() extensions to let the user control this.

Code that creates the default client.

Genbox commented 3 years ago

Here is my proposal:

  1. Create a configuration class for HttpClientFactoryNetworkDriver.
  2. Have a HttpClientName property in the config
  3. Call _clientFactory.CreateClient(config.HttpClientName)

Would that support the use case?

LordMike commented 3 years ago

It will.

As a convenience, you can add the following overloads:

Genbox commented 3 years ago

The second overload is already present. I'll keep that as the only one to avoid polluting the API with lots of different overloads.

Genbox commented 3 years ago

This was added in 41da3457cf883eaa7a900cf404a8c2221f4d8a0e