Add the ability to register Refit clients as keyed services by fubar-coder · Pull Request #1981 · reactiveui/refit

This PR fixes #1876.

  1. Added new constructor to AuthenticatedHttpClientHandler which doesn't automatically set the InnerHandler property
  2. Adds extension methods to register the Refit client as keyed service
  3. Added unit tests

Why did I add the new constructor to AuthenticatedHttpClientHandler?

  • To keep the PR as small as possible by avoiding the duplication of code
  • Enable the a behavior compatible with IHttpClientBuilder by ...
    • ... avoiding the usage of obsolete functions
    • ... avoid setting InnerHandler, because this will be done by the builder itself

Future changes (not scope of this PR)

  • AuthenticatedHttpClientHandler: Remove the old constructor
  • AuthenticatedHttpClientHandler: Remove the innerHandler parameter for the new constructor
  • AuthenticatedHttpClientHandler: Fix the call sites
  • Don't call the obsoleted ConfigureHttpMessageHandlerBuilder
  • Fix the unit tests

Behavioral changes

When no httpClientName was specified, the UniqueName.ForType<T> is used and the string representation of the serviceKey (when not null or empty string) gets appended to the unique type name, e.g. Refit.Implementation.Generated+IFooWithOtherAttribute, Refit.Tests, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null, ServiceKey=keyed