美文网首页开源框架-SpringCloud系列
SpringCloud Gateway-添加cookies的过滤

SpringCloud Gateway-添加cookies的过滤

作者: 侯文_ad82 | 来源:发表于2020-02-28 16:56 被阅读0次

    @Component

    public class CookiesFilter  implements Ordered, GlobalFilter {

    @Override

        public Mono  filter(ServerWebExchange exchange, GatewayFilterChain chain) {

    ServerHttpRequest request = exchange.getRequest().mutate().headers((httpHeaders) -> {

               String csrf =new HttpCookie("csrf", "3838a26d-07f7-11e9-b5f7").toString();

                String ssn =new HttpCookie("ssn", "MTU0NT").toString();

                httpHeaders.set("Cookie", csrf+";"+ssn);

            }).build();

            return chain.filter(exchange.mutate().request(request).build());

        }

    @Override

        public int getOrder() {

               return -100;

        }

    }

    相关文章

      网友评论

        本文标题:SpringCloud Gateway-添加cookies的过滤

        本文链接:https://www.haomeiwen.com/subject/xjilhhtx.html