Further Gateway Features

There are a lot of further things to explore with Spring Cloud Gateway and reactive streams programming.

Default and Global Filters

There are still more features available like global filtersarrow-up-right and [default filters]. These kind of filters apply to all routes.

Default Filters:

spring:
  cloud:
    gateway:
      default-filters:
      - AddResponseHeader=X-My-Response-Default, Default-Value

Global Filters:

@Configuration
class GlobalFilterConfiguration {

    @Bean
    public GlobalFilter customFilter() {
        return new CustomGlobalFilter();
    }

    public class CustomGlobalFilter implements GlobalFilter, Ordered {

        @Override
        public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
            log.info("custom global filter");
            return chain.filter(exchange);
        }

        @Override
        public int getOrder() {
            return -1;
        }
    }
}

Custom Filters

Custom Route Predicates


If you liked the workshop, disliked some part, or you have suggestions for improvement: Any feedback on this hands-on workshop is highly appreciated.

Just email andreas.falk(at)novatec-gmbh.de or contact me via Twitter (@andifalk).

Last updated