Best way to cancel a YARP request #1586
-
Assume I want to check the existence of certain headers for a specific route - and if not present cancel the request and return a specific error code. What would be the best extensibility point for that. It would be very similar to a transform provider, but it does not look like this is designed to return errors. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can specify routing rules based on request headers, see https://microsoft.github.io/reverse-proxy/articles/header-routing.html "myRoute" : {
"ClusterId": "myCluster",
"Match": {
"Path": "{**catch-all}",
"Headers": [
{
"Name": "X-Custom-Header",
"Mode": "Exists"
}
]
}
} You can then have a different route match the request, or let ASP.NET Core's routing reject the request if it does not match any route. If you need more flexibility, such as a more complex decision process to determine whether to proxy the request, or sending a custom response, consider using a middleware. See https://microsoft.github.io/reverse-proxy/articles/middleware.html#send-an-immediate-response |
Beta Was this translation helpful? Give feedback.
You can specify routing rules based on request headers, see https://microsoft.github.io/reverse-proxy/articles/header-routing.html
You can then have a different route match the request, or let ASP.NET Core's routing reject the request if it does not match any route.
If you need more flexibility, such as a more complex decision process to determine whether to proxy the request, or sending a custom response, consider using a middleware. See https://microsoft.github.io/reverse-proxy/articles/middleware.htm…