springcloud-gateway网关(自定义filter)
@Configuration @Slf4j public class CustomGlobalFilter implements GlobalFilter, Ordered { @Override public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { log.info("进入自定义的filter"); if (exchange.getRequest().getQueryParams().get("username") != null) { log.info("用户身份信息合法,放行请求继续执行!!!"); return chain.filter(exchange);//放行请求 } log.info("非法用户,拒绝访问!!!"); return exchange.getResponse().setComplete(); } @Override public int getOrder() { return -1; } }