New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
开放健康检查的URL /actuator/** #287
Labels
type: question
Further information is requested
Comments
在前面的拦截器里面做就好了 |
你好, 我仔细学习了WebFlux的过滤器的用法,写了下面段代码去解决这个问题,但是目前还有一个疑问:当请求匹配到路由白名单之后,如果不在继续执行后面的过滤器链,需要如何返回一个Mono?(具体代码在倒数第5行)。谢谢你的解答。 @Slf4j
@Order(Integer.MIN_VALUE)
public class ActuatorFilter implements WebFilter {
private static final String[] FILTER_TAG = {"/actuator/**", "/health_check"};
/**
* 过滤策略
* @param exchange
* @param chain
* @return
*/
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
ServerHttpRequest request = Objects.requireNonNull(exchange).getRequest();
String urlPath = request.getURI().getPath();
if (FilterUtil.checkWhiteList(urlPath, FILTER_TAG)) {
//
log.info("请求[{}]在白名单之中,允许访问.", urlPath);
// 不在调用其他的过滤器,应该如何返回
return Mono.empty();
}
return chain.filter(exchange);
}
} |
请问你是怎么获取到/actuator/**下所有信息的? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
您好,我在文档 《网关过滤 springboot健康检查》一节中,看到通过自定义Filter可以解决健康检查问题,但里面只是直接写死返回Health UP 的json对象, 而我在项目中引用了Springboot的actuator的依赖,如何将actuator对应的 /actuator/** 下的详细信息都暴露出来?
目前我如果访问/actuator下的路径,soul会把它拦截返回
{code: -107,message: "未能匹配选择器,请检查你的选择器配置!",data: null}
,但是我只是想访问这个路径,而不是需要做转发。请问有什么好的解决方法吗?谢谢你的解答。The text was updated successfully, but these errors were encountered: