Last active
February 10, 2018 22:19
-
-
Save fitzoh/266d705448a6821552b96a0462358281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class RouteServiceForwardingFilter implements GatewayFilter { | |
@Override | |
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { | |
try { | |
String forwardUrl = exchange.getRequest().getHeaders().get(FORWARDED_URL).get(0); | |
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, new URI(forwardUrl)); | |
return chain.filter(exchange); | |
} catch (URISyntaxException e) { | |
exchange.getResponse().setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR); | |
return Mono.empty(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment