【发布时间】:2018-11-01 23:35:40
【问题描述】:
我们正在使用带有 Spring Boot 2 和响应式 webflux 模块的 Spring Cloud Gateway。 有一个为其中一条路由添加的身份验证过滤器。 现在,如果我们抛出一个带有特定状态码的 RuntimeException,它实际上并没有启动。 之前这个身份验证检查是 Spring 中 HandlerInterceptor 的一部分,现在我们不能将 web 模块与 webflux 一起使用(来自 Spring 云网关的冲突)。 例如:
@Override
public GatewayFilter apply(Object config) {
ServerHttpRequest httpRequest = exchange.getRequest();
if(!someUtil.validRequest(httpRequest) {
throw new RuntimeException("Throw 401 Unauthorized with Custom error code and message");
}
}
目前实际响应总是给出 500 内部服务器错误。 这是从哪里来的?我们可以在这里从过滤器中获取错误吗?
【问题讨论】:
标签: spring spring-cloud-gateway