企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
```java @Slf4j @Component public class MyGateWayFilter implements GlobalFilter, Ordered { @Override public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { log.info("MyGateWayFilter: " + new Date()); //请求必须携带参数 uname 才允许通过 String uname = exchange.getRequest().getQueryParams().getFirst("uname"); if (uname == null) { log.info("用户名为空,非法用户。"); exchange.getResponse().setStatusCode(HttpStatus.NOT_ACCEPTABLE); return exchange.getResponse().setComplete(); } return chain.filter(exchange); } @Override public int getOrder() { return 0; } } ``` http://localhost:9527/payment/get/uname?uname=zhangsan ``` serverPort:8002,uname=zhangsan ```