public String buildProxyPath(Request request, RouteState state) { Optional<String> pathSuffix = state .route() .groups(request.path()) // apply the regex .entrySet() .stream() // stream the entry set of matches .filter(e -> e.getKey().equals("path")) // find the entry with key path .map(e -> e.getValue()) // extract the value (aka what did the regex match) .findFirst(); // extract the first (Optional) result return pathSuffix .map(config.proxyPath()::concat) // append the path suffix (if it exists) .orElse(config.proxyPath()); // use the provided path with no suffix }
public ProxyRouteConfig build() { return new ProxyRouteConfig( valueOrFallback(methods, fallbackObject.methods()), valueOrFallback(host, fallbackObject.host()), valueOrFallback(path, fallbackObject.path()), valueOrFallback(permissionNeeded, fallbackObject.permissionNeeded()), valueOrFallback(clientConfigs, fallbackObject.clientConfigs()), valueOrFallback(proxyHostPolicy, fallbackObject.proxyHostPolicy()), valueOrFallback(proxyHost, fallbackObject.proxyHost()), valueOrFallback(proxyPath, fallbackObject.proxyPath())); }
assertEquals(expectedProxyHostPolicy, subject.proxyHostPolicy()); assertEquals(expectedProxyHost, subject.proxyHost()); assertEquals(expectedProxyPath, subject.proxyPath());