Last active
February 10, 2018 21:10
-
-
Save fitzoh/7f4c4acc2a8145dc958e4c06560f0fe1 to your computer and use it in GitHub Desktop.
simple-gateway-route-service
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
@Bean | |
public RouteLocator customRouteLocator(RouteLocatorBuilder builder, SimpleLoggingFilter loggingFilter) { | |
return builder.routes() | |
.route(r -> | |
r.header(FORWARDED_URL, ".*") | |
.and() | |
.header(PROXY_METADATA, ".*") | |
.and() | |
.header(PROXY_SIGNATURE, ".*") | |
.filters(f -> f.add(loggingFilter)) | |
.uri("http://google.com:80")) | |
.build(); | |
} |
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 SimpleLoggingFilter implements GatewayFilter { | |
private static final Logger log = LoggerFactory.getLogger(SimpleLoggingFilter.class); | |
@Override | |
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { | |
log.info("Method:{} Host:{} Path:{} QueryParams:{}", | |
exchange.getRequest().getMethod(), | |
exchange.getRequest().getURI().getHost(), | |
exchange.getRequest().getURI().getPath(), | |
exchange.getRequest().getQueryParams()); | |
return chain.filter(exchange); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment