List of usage examples for io.netty.handler.codec.http QueryStringDecoder rawPath
public String rawPath()
From source file:io.gravitee.gateway.core.endpoint.resolver.impl.TargetEndpointResolver.java
License:Apache License
private String encode(String uri, MultiValueMap<String, String> parameters, ExecutionContext executionContext) { QueryStringDecoder decoder = new QueryStringDecoder(uri); Map<String, List<String>> queryParameters = decoder.parameters(); // Merge query parameters from user target into incoming request query parameters for (Map.Entry<String, List<String>> param : queryParameters.entrySet()) { parameters.put(param.getKey(), param.getValue()); }//from ww w.j av a2 s .com // Retrieve useRawPath config from ExecutionContext Boolean useRawPath = (Boolean) executionContext .getAttribute(ExecutionContext.ATTR_ENDPOINT_RESOLVER_USE_RAW_PATH); if (Boolean.TRUE.equals(useRawPath)) { return decoder.rawPath(); } else { // Path segments must be encoded to avoid bad URI syntax String path = decoder.path(); String[] segments = path.split(URI_PATH_SEPARATOR); StringBuilder builder = new StringBuilder(); for (String pathSeg : segments) { builder.append(UrlEscapers.urlPathSegmentEscaper().escape(pathSeg)).append(URI_PATH_SEPARATOR); } if (path.charAt(path.length() - 1) == URI_PATH_SEPARATOR_CHAR) { return builder.toString(); } else { return builder.substring(0, builder.length() - 1); } } }