[BAEL-3311] Code formatting

This commit is contained in:
Philippe 2020-01-19 13:46:57 -03:00
parent 3d6d0765a3
commit 68dee74200
3 changed files with 23 additions and 25 deletions

View File

@ -8,8 +8,8 @@ public class CustomRoutersGatewayApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(CustomRoutersGatewayApplication.class)
.profiles("customroutes")
.run(args);
.profiles("customroutes")
.run(args);
}
}

View File

@ -24,15 +24,15 @@ public class CustomPredicatesConfig {
public RouteLocator routes(RouteLocatorBuilder builder, GoldenCustomerRoutePredicateFactory gf ) {
return builder.routes()
.route("dsl_golden_route", r -> r.path("/dsl_api/**")
.filters(f -> f.stripPrefix(1))
.uri("https://httpbin.org")
.predicate(gf.apply(new Config(true, "customerId"))))
.route("dsl_common_route", r -> r.path("/dsl_api/**")
.filters(f -> f.stripPrefix(1))
.uri("https://httpbin.org")
.predicate(gf.apply(new Config(false, "customerId"))))
.build();
.route("dsl_golden_route", r -> r.path("/dsl_api/**")
.filters(f -> f.stripPrefix(1))
.uri("https://httpbin.org")
.predicate(gf.apply(new Config(true, "customerId"))))
.route("dsl_common_route", r -> r.path("/dsl_api/**")
.filters(f -> f.stripPrefix(1))
.uri("https://httpbin.org")
.predicate(gf.apply(new Config(false, "customerId"))))
.build();
}
}

View File

@ -41,27 +41,25 @@ public class GoldenCustomerRoutePredicateFactory extends AbstractRoutePredicateF
return (ServerWebExchange t) -> {
List<HttpCookie> cookies = t.getRequest()
.getCookies()
.get(config.getCustomerIdCookie());
.getCookies()
.get(config.getCustomerIdCookie());
boolean isGolden;
if ( cookies == null || cookies.isEmpty()) {
isGolden = false;
}
else {
String customerId = cookies.get(0).getValue();
isGolden = goldenCustomerService.isGoldenCustomer(customerId);
}
boolean isGolden;
if ( cookies == null || cookies.isEmpty()) {
isGolden = false;
}
else {
String customerId = cookies.get(0).getValue();
isGolden = goldenCustomerService.isGoldenCustomer(customerId);
}
return config.isGolden()?isGolden:!isGolden;
return config.isGolden()?isGolden:!isGolden;
};
}
@Validated
public static class Config {
public static class Config {
boolean isGolden = true;
@NotEmpty