All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.plugin.strategy.gateway.context.GatewayStrategyContextHolder Maven / Gradle / Ivy

package com.nepxion.discovery.plugin.strategy.gateway.context;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import java.net.URI; import org.springframework.http.HttpCookie; import org.springframework.web.server.ServerWebExchange; import com.nepxion.discovery.plugin.strategy.context.AbstractStrategyContextHolder; public class GatewayStrategyContextHolder extends AbstractStrategyContextHolder { public ServerWebExchange getExchange() { return GatewayStrategyContext.getCurrentContext().getExchange(); } @Override public String getHeader(String name) { ServerWebExchange exchange = getExchange(); if (exchange == null) { // LOG.warn("The ServerWebExchange object is lost for thread switched, or it is got before context filter probably"); return null; } return exchange.getRequest().getHeaders().getFirst(name); } @Override public String getParameter(String name) { ServerWebExchange exchange = getExchange(); if (exchange == null) { // LOG.warn("The ServerWebExchange object is lost for thread switched, or it is got before context filter probably"); return null; } return exchange.getRequest().getQueryParams().getFirst(name); } public HttpCookie getHttpCookie(String name) { ServerWebExchange exchange = getExchange(); if (exchange == null) { // LOG.warn("The ServerWebExchange object is lost for thread switched, or it is got before context filter probably"); return null; } return exchange.getRequest().getCookies().getFirst(name); } @Override public String getCookie(String name) { HttpCookie cookie = getHttpCookie(name); if (cookie != null) { return cookie.getValue(); } return null; } public URI getURI() { ServerWebExchange exchange = getExchange(); if (exchange == null) { // LOG.warn("The ServerWebExchange object is lost for thread switched, or it is got before context filter probably"); return null; } return exchange.getRequest().getURI(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy