These are chat archives for spring-cloud/spring-cloud

Jan 2018
Andrew Fitzgerald
Jan 13 2018 03:44
@spencergibb, In spring-cloud-gateway is there an easy way to set the uri of route based on a header?
The use case I’m thinking of is a PCF route service
Or would it make more sense to just use webflux and make the downstream request manually?
Jan 13 2018 19:18
Hi guys, I'm trying to use zuul (or may be something else) to aggregate data from all my microservices. Each microservice will expose his permissions at the same endpoint /api/permissions, and the gateway would (using probably zuul) request from all and aggregate the data
any idea on how to do that using spring cloud?
Andrew Fitzgerald
Jan 13 2018 23:33

Think I’ve got it btw:

public class RouteServiceForwardingFilter implements GatewayFilter {

    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) {
            return Mono.empty();


    public RouteLocator customRouteLocator(RouteLocatorBuilder builder, RouteServiceForwardingFilter forwardFilter) {
        return builder.routes()
                .route(r ->
                        r.header(FORWARDED_URL, ".*")
                                .header(PROXY_METADATA, ".*")
                                .header(PROXY_SIGNATURE, ".*")
                                .filter(forwardFilter, 10000)