【发布时间】:2021-12-06 03:49:32
【问题描述】:
如果在请求转换中不满足特定条件,我无法弄清楚如何提前停止 YARP 请求并返回自定义响应。
builderContext.AddRequestTransform(async transformContext =>
{
[...]
if (!condition)
{
// TODO: stop request and return response
}
[...]
});
我尝试像对中间件所做的那样简单地将 transformContext.HttpContext.Response.Status 设置为非成功状态代码,但这似乎不起作用,而且我无法找到解决此问题的其他方法.
【问题讨论】:
标签: c# asp.net asp.net-core asp.net-core-3.1 yarp