RestEase
RestEase copied to clipboard
[suggestion] Add ctor to ReseEase that allow to add both RequestModifier and HttpMessageHandler
Discussed in https://github.com/canton7/RestEase/discussions/231
Originally posted by Legion-ale July 21, 2022 As explained in the title i'm in the following situation:
private readonly Microsoft.Extensions.Http.PolicyHttpMessageHandler retryPolicyHandler = new Microsoft.Extensions.Http.PolicyHttpMessageHandler(
Policy.HandleResult<HttpResponseMessage>(r => r.StatusCode == System.Net.HttpStatusCode.BadGateway)
.RetryAsync()
);
private readonly RequestModifier proxyHandler = async (request, cancellationToken) =>
{
//Lot of code to set some proxy stuff before sending the call
};
But when i try to inizialize RestEase i cannot add both to the ctor (even if i use new RestClient(...)) and i need to choose only one of the 2 following ctors:
RestClient.For<IWebApi>(API_URL, proxyHandler); (ctor that accept RequestModifier)
RestClient.For<IWebApi>(API_URL, retryPolicyHandler); (ctor that accept HttpMessageHandler)
There are not public members that allow me to edit that configuration in a second time because HttpClient is a private property (as it should be).
Thanks and sorry for my bad english :) L-