What is the correct way to return an error/status code in HttpTransformer
?
#1724
Answered
by
karelz
VictorioBerra
asked this question in
Q&A
-
Inside IE: public override async ValueTask TransformRequestAsync(HttpContext httpContext, HttpRequestMessage proxyRequest, string destinationPrefix)
{HttpResponseMessage
// Copy all request headers
await base.TransformRequestAsync(httpContext, proxyRequest, destinationPrefix);
var queryContext = new Yarp.ReverseProxy.Transforms.QueryTransformContext(httpContext.Request);
// Remove a header
proxyRequest.Headers.Remove("X-DownstreamApi-Token");
var token = httpContext.Request.Headers["X-DownstreamApi-Token"];
if (token == Microsoft.Extensions.Primitives.StringValues.Empty)
{
// <-------------- return 401?
}
// ... Also how to do the same thing in |
Beta Was this translation helpful? Give feedback.
Answered by
karelz
May 17, 2022
Replies: 1 comment 7 replies
-
Being discussed in #1701 |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
karelz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Being discussed in #1701