Microservices with Spring Cloud, Part 4 Routing and Filtering with Spring Cloud Gateway
In microservice environments, it is helpful if certain functionalities such as authentication, logging or the collection of metrics work across all services; and that – for several development teams – also in the same way.
The solution to this problem is to leave these cross cutting concerns to a central instance, an API Gateway service. Incoming calls then no longer run directly from the client to the service, but take the detour via the gateway and are routed from there to the actual recipient. Actions such as logging, security checks and other functionalities can then be implemented on the central gateway using filters.
There are several of these gateways for Spring Cloud. Here we introduce the native Spring Cloud Gateway. Compared to the well-known and slightly older Zuul from the Netflix stack, Spring Cloud Gateway relies on newer technologies such as Spring 5, Spring Boot 2 and Reactor and supports websockets.