Last active
June 26, 2018 15:33
-
-
Save tillmannheigel/abdef1bd03908689e10bcb22c94059c6 to your computer and use it in GitHub Desktop.
Revisions
-
Tillmann Heigel revised this gist
Jun 26, 2018 . No changes.There are no files selected for viewing
-
Tillmann Heigel renamed this gist
Jun 26, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Tillmann Heigel revised this gist
Jun 26, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,6 +33,6 @@ public class Application { } public static void main(String[] args) { SpringApplication.run(Application.class, args); } } -
Tillmann Heigel created this gist
Jun 26, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ @SpringBootApplication public class Application { @Bean public RouteLocator staticRoutes(RouteLocatorBuilder builder) { return builder .routes() .route(defaultRoute()) .build(); } private Function<PredicateSpec, Route.Builder> defaultRoute() { return r -> r .path("/**") .filters(defaultFilters()) .uri("lb://application:8080"); } private Function<GatewayFilterSpec, UriSpec> defaultFilters() { return f -> f .preserveHostHeader() .filter(this::addCustomHeader) .addResponseHeader("x-static-router-header", random() + ""); } private Mono<Void> addCustomHeader(ServerWebExchange exchange, GatewayFilterChain chain) { exchange.getResponse().getHeaders().add("x-dynamic-router-header", random() + ""); return chain.filter(exchange); } private double random(){ return Math.random(); } public static void main(String[] args) { SpringApplication.run(FrocRouterApplication.class, args); } }