[BAEL-3311] Code formatting
This commit is contained in:
parent
3d6d0765a3
commit
68dee74200
@ -8,8 +8,8 @@ public class CustomRoutersGatewayApplication {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpringApplicationBuilder(CustomRoutersGatewayApplication.class)
|
new SpringApplicationBuilder(CustomRoutersGatewayApplication.class)
|
||||||
.profiles("customroutes")
|
.profiles("customroutes")
|
||||||
.run(args);
|
.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -24,15 +24,15 @@ public class CustomPredicatesConfig {
|
|||||||
public RouteLocator routes(RouteLocatorBuilder builder, GoldenCustomerRoutePredicateFactory gf ) {
|
public RouteLocator routes(RouteLocatorBuilder builder, GoldenCustomerRoutePredicateFactory gf ) {
|
||||||
|
|
||||||
return builder.routes()
|
return builder.routes()
|
||||||
.route("dsl_golden_route", r -> r.path("/dsl_api/**")
|
.route("dsl_golden_route", r -> r.path("/dsl_api/**")
|
||||||
.filters(f -> f.stripPrefix(1))
|
.filters(f -> f.stripPrefix(1))
|
||||||
.uri("https://httpbin.org")
|
.uri("https://httpbin.org")
|
||||||
.predicate(gf.apply(new Config(true, "customerId"))))
|
.predicate(gf.apply(new Config(true, "customerId"))))
|
||||||
.route("dsl_common_route", r -> r.path("/dsl_api/**")
|
.route("dsl_common_route", r -> r.path("/dsl_api/**")
|
||||||
.filters(f -> f.stripPrefix(1))
|
.filters(f -> f.stripPrefix(1))
|
||||||
.uri("https://httpbin.org")
|
.uri("https://httpbin.org")
|
||||||
.predicate(gf.apply(new Config(false, "customerId"))))
|
.predicate(gf.apply(new Config(false, "customerId"))))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,27 +41,25 @@ public class GoldenCustomerRoutePredicateFactory extends AbstractRoutePredicateF
|
|||||||
|
|
||||||
return (ServerWebExchange t) -> {
|
return (ServerWebExchange t) -> {
|
||||||
List<HttpCookie> cookies = t.getRequest()
|
List<HttpCookie> cookies = t.getRequest()
|
||||||
.getCookies()
|
.getCookies()
|
||||||
.get(config.getCustomerIdCookie());
|
.get(config.getCustomerIdCookie());
|
||||||
|
|
||||||
boolean isGolden;
|
boolean isGolden;
|
||||||
if ( cookies == null || cookies.isEmpty()) {
|
if ( cookies == null || cookies.isEmpty()) {
|
||||||
isGolden = false;
|
isGolden = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String customerId = cookies.get(0).getValue();
|
String customerId = cookies.get(0).getValue();
|
||||||
isGolden = goldenCustomerService.isGoldenCustomer(customerId);
|
isGolden = goldenCustomerService.isGoldenCustomer(customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return config.isGolden()?isGolden:!isGolden;
|
return config.isGolden()?isGolden:!isGolden;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Validated
|
@Validated
|
||||||
public static class Config {
|
public static class Config {
|
||||||
|
|
||||||
boolean isGolden = true;
|
boolean isGolden = true;
|
||||||
|
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user