ProLesson 5.2Intermediate2 min readUpdated 31 October 2026
Spring Cloud Gateway: Routes, Predicates & Filters
Configure dynamic routing, path predicates, and gateway filters in Spring Cloud Gateway using YAML and Java.
Spring Cloud Gateway is built on three fundamental concepts:
- Route: The basic building block consisting of an ID, a destination URI, a collection of Predicates, and a collection of Filters.
- Predicate: A boolean condition that matches against anything in the HTTP request (path, method, headers, query params). If the predicate evaluates to
true, the route is matched. - Filter: A pre-processing or post-processing interceptor that modifies the incoming HTTP request before forwarding it, or modifies the outgoing HTTP response before returning it to the client.
Let's configure a production gateway.
01Setting Up Spring Cloud Gateway in Spring Boot 3
Add the dependency in pom.xml:
xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>Loading the rest of the lesson…