ServerWebExchange 中获取 Token
private String getToken(ServerWebExchange exchange) { String authToken = exchange.getRequest().getHeaders().getFirst("Token"); if (StrUtil.isBlank(authToken)) { MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams(); authToken = queryParams.getFirst("Token"); } if (StrUtil.isBlank(authToken)) { MultiValueMap<String, HttpCookie> cookies = exchange.getRequest().getCookies(); HttpCookie cookie = cookies.getFirst("Token"); authToken = cookie != null ? cookie .getValue() : null; } return authToken; }
标签:authToken,网关,exchange,Spring,getRequest,Token,cookie,getFirst,Cloud From: https://www.cnblogs.com/yangchongxing/p/17336162.html