如何在Spring Cloud Gateway中控制会话创建?

时间:2019-01-10 12:09:29

标签: spring spring-cloud-gateway

我怎么不能让Spring Cloud Gateway在这里创建会话,就像我们以前在http会话中所做的那样:

HttpSession会话= req.getSession(false); 下一行已经默认创建了一个会话,我知道在春天有一个叫做IF_REQUIRED的东西,但是在Spring Cloud Gateway中似乎不起作用。

公共类AuthenticationFilter扩展了AbstractGatewayFilterFactory {

private final static Logger log = LoggerFactory.getLogger(AuthenticationFilter.class);

@Override
public GatewayFilter apply(Object config) {
    return (exchange, chain) -> {
        ServerHttpRequest req = exchange.getRequest();
        ServerHttpResponse res = exchange.getResponse();
        Mono<WebSession> session = exchange.getSession();// this line have session ready, although different kind of session than http session

0 个答案:

没有答案