Add the ability to register Refit clients as keyed services#1981
Conversation
This can be achieved by adding `$";{serviceKey}"` to the `httpClientName`
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1981 +/- ##
==========================================
- Coverage 87.73% 83.03% -4.71%
==========================================
Files 33 37 +4
Lines 2348 2640 +292
Branches 294 380 +86
==========================================
+ Hits 2060 2192 +132
- Misses 208 362 +154
- Partials 80 86 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi Mark, thank you for this, please could you make your next contribution to provide suitable tests to ensure this change doesn't become affected by future additions and alterations within the code base. |
|
@ChrisPulman Hi, I added some tests, but it was obviously not exhaustive enough, as I wasn't sure how I can test that the created Refit clients use the correct |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR fixes #1876.
AuthenticatedHttpClientHandlerwhich doesn't automatically set theInnerHandlerpropertyWhy did I add the new constructor to
AuthenticatedHttpClientHandler?IHttpClientBuilderby ...InnerHandler, because this will be done by the builder itselfFuture changes (not scope of this PR)
AuthenticatedHttpClientHandler: Remove the old constructorAuthenticatedHttpClientHandler: Remove theinnerHandlerparameter for the new constructorAuthenticatedHttpClientHandler: Fix the call sitesConfigureHttpMessageHandlerBuilderBehavioral changes
When no
httpClientNamewas specified, theUniqueName.ForType<T>is used and the string representation of theserviceKey(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