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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-49
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ services
56
56
*[Removing headers](#removing-headers)
57
57
*[Passing state into DelegatingHandlers](#passing-state-into-delegatinghandlers)
58
58
*[Support for Polly and Polly.Context](#support-for-polly-and-pollycontext)
59
-
*[Target Interface type and method info](#target-interface-type-and-method-info)
59
+
*[Target Interface type](#target-interface-type)
60
60
*[MethodInfo of the method on the Refit client interface that was invoked](#methodinfo-of-the-method-on-the-refit-client-interface-that-was-invoked)
61
61
*[Multipart uploads](#multipart-uploads)
62
62
*[Retrieving the response](#retrieving-the-response)
@@ -882,54 +882,6 @@ class RequestPropertyHandler : DelegatingHandler
882
882
883
883
Note: in .NET 5 `HttpRequestMessage.Properties` has been marked `Obsolete` and Refit will instead populate the value into the new `HttpRequestMessage.Options`. Refit provides `HttpRequestMessageOptions.InterfaceTypeKey` and `HttpRequestMessageOptions.RestMethodInfoKey` to respectively access the interface type and REST method info from the options.
884
884
885
-
#### MethodInfo of the method on the Refit client interface that was invoked
886
-
887
-
There may be times when you want access to the `MethodInfo` of the method on the Refit client interface that was invoked. An example is where you
888
-
want to decorate the method with a custom attribute in order to control some aspect of behavior in a `DelegatingHandler`:
889
-
890
-
```csharp
891
-
publicinterfaceISomeAPI
892
-
{
893
-
[SomeCustomAttribute("SomeValue")]
894
-
[Get("/{id}")]
895
-
Task<ApiResponse<SomeClass>> GetById(intid);
896
-
}
897
-
```
898
-
To make the `MethodInfo` available you need to opt-in via the `RefitSettings` like so:
/// Creates a new <see cref="RefitSettings"/> instance with the specified parameters
34
-
/// </summary>
35
-
/// <param name="contentSerializer">The <see cref="IHttpContentSerializer"/> instance to use</param>
36
-
/// <param name="urlParameterFormatter">The <see cref="IUrlParameterFormatter"/> instance to use (defaults to <see cref="DefaultUrlParameterFormatter"/>)</param>
37
-
/// <param name="formUrlEncodedParameterFormatter">The <see cref="IFormUrlEncodedParameterFormatter"/> instance to use (defaults to <see cref="DefaultFormUrlEncodedParameterFormatter"/>)</param>
38
-
/// <param name="injectMethodInfoAsProperty">Controls injecting the <see cref="MethodInfo"/> of the method on the Refit client interface that was invoked into the HttpRequestMessage.Options (defaults to false)</param>
39
-
#else
40
30
/// <summary>
41
31
/// Creates a new <see cref="RefitSettings"/> instance with the specified parameters
42
32
/// </summary>
43
33
/// <param name="contentSerializer">The <see cref="IHttpContentSerializer"/> instance to use</param>
44
34
/// <param name="urlParameterFormatter">The <see cref="IUrlParameterFormatter"/> instance to use (defaults to <see cref="DefaultUrlParameterFormatter"/>)</param>
45
35
/// <param name="formUrlEncodedParameterFormatter">The <see cref="IFormUrlEncodedParameterFormatter"/> instance to use (defaults to <see cref="DefaultFormUrlEncodedParameterFormatter"/>)</param>
46
-
/// <param name="injectMethodInfoAsProperty">Controls injecting the <see cref="MethodInfo"/> of the method on the Refit client interface that was invoked into the HttpRequestMessage.Properties (defaults to false)</param>
/// Optional Key-Value pairs, which are displayed in the property <see cref="HttpRequestMessage.Options"/> or <see cref="HttpRequestMessage.Properties"/>.
/// Controls injecting the <see cref="MethodInfo"/> of the method on the Refit client interface that was invoked into the HttpRequestMessage.Options (defaults to false)
110
-
/// </summary>
111
-
#else
112
-
/// <summary>
113
-
/// Controls injecting the <see cref="MethodInfo"/> of the method on the Refit client interface that was invoked into the HttpRequestMessage.Properties (defaults to false)
0 commit comments