zoukankan      html  css  js  c++  java
  • gateway 过滤器

    @Component
    @Configuration
    public class GateWayFilter implements GlobalFilter, Ordered {
    
    
        @Override
        public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
    
            ServerHttpRequest request = exchange.getRequest();
            ServerHttpResponse response = exchange.getResponse();
            System.out.println("request: " + JSONUtil.toJsonStr(request));
    
            //--------   uri  ----------
            URI uri = request.getURI();
            System.out.println("uri: " + JSONUtil.toJsonStr(uri));
            String path = uri.getPath();
            String scheme = uri.getScheme();
            int port = uri.getPort();
            String authority = uri.getAuthority();
            String query = uri.getQuery();
            String host = uri.getHost();
            String schemeSpecificPart = uri.getSchemeSpecificPart();
    
            // -----------   body  ------------
            Flux<DataBuffer> body = request.getBody();
    
    
            // -----------  query  ------------
            System.out.println();
            MultiValueMap<String, String> queryParams = request.getQueryParams();
            Set<String> keys = queryParams.keySet();
            for (String key : keys) {
                System.out.print("  key:" + key + " value:" + queryParams.getFirst(key));
            }
            System.out.println();
            HttpHeaders headers = request.getHeaders();
    
    
    //uri: {"path":"/payment/get/1","scheme":"http","port":9527,"authority":"localhost:9527","query":"realName=draymond&password=123456","host":"localhost","schemeSpecificPart":"//localhost:9527/payment/get/1?realName=draymond&password=123456"}
            return chain.filter(exchange);
        }

      请求参数 url信息

    body信息

    head信息

  • 相关阅读:
    最重要的是动手去做
    java中的native关键字
    用ant重新编译jdk加入调试信息
    UnSupported Encoding错误
    mysql中查看字符集的cmd指令
    java中的IO流读取文件
    分享一个jdk源码链接
    mysql dos启动出现1067错误的解决方法
    vs2010中的外部依赖项的含义
    vs2010中出现:程序管理器匹配不正确错误
  • 原文地址:https://www.cnblogs.com/draymond/p/12793894.html
Copyright © 2011-2022 走看看