-
Hi, from the documentation I could not find out, if custom delegating handlers (http and websockets) like in ocelot are supported in YARP I saw in some of the pull requet that such issues were requested and also implemented but I can not find the changes in the source code, probably they are not merged e.g. #869 Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
If you're using direct forwarding, you control the If you're using the full YARP middleware ( E.g. services.AddSingleton<IForwarderHttpClientFactory, CustomHttpClientFactory>();
private sealed class CustomHttpClientFactory : ForwarderHttpClientFactory
{
protected override WrapHandler(ForwarderHttpClientContext context, HttpMessageHandler handler)
{
return new MyHandler(handler);
}
} |
Beta Was this translation helpful? Give feedback.
-
Is there a specific reason it needs to be delegating handlers? Yes those work in YARP as shown above, but you can also use aspnetcore middleware and YARP request/response transforms. All three have different strengths and weaknesses. What are you trying to accomplish? |
Beta Was this translation helpful? Give feedback.
If you're using direct forwarding, you control the
HttpClientHandler
instance yourself, so you can customize it however you wish.If you're using the full YARP middleware (
.MapReverseProxy()
), you can inject custom delegating handlers by implementing a customIForwarderHttpClientFactory
and registering it in DI. See https://microsoft.github.io/reverse-proxy/articles/http-client-config.htmlE.g.