Spring Cloud Gateway


This project provides a library for building an API Gateway on top of Spring WebFlux. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.


Spring Cloud Gateway features:

  • Built on Spring Framework 5, Project Reactor and Spring Boot 2.0

  • Able to match routes on any request attribute.

  • Predicates and filters are specific to routes.

  • Circuit Breaker integration.

  • Spring Cloud DiscoveryClient integration

  • Easy to write Predicates and Filters

  • Request Rate Limiting

  • Path Rewriting

Getting Started

public class DemogatewayApplication {
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
		return builder.routes()
			.route("path_route", r -> r.path("/get")
			.route("host_route", r ->"*")
			.route("rewrite_route", r ->"*")
				.filters(f -> f.rewritePath("/foo/(?<segment>.*)", "/${segment}"))
			.route("hystrix_route", r ->"*")
				.filters(f -> f.hystrix(c -> c.setName("slowcmd")))
			.route("hystrix_fallback_route", r ->"*")
				.filters(f -> f.hystrix(c -> c.setName("slowcmd").setFallbackUri("forward:/hystrixfallback")))
			.route("limit_route", r -> r
				.filters(f -> f.requestRateLimiter(c -> c.setRateLimiter(redisRateLimiter())))

To run your own gateway use the spring-cloud-starter-gateway dependency.

Spring Initializr

Quickstart Your Project

Bootstrap your application with Spring Initializr.


Each Spring project has its own; it explains in great details how you can use project features and what you can achieve with them.
3.0.3 CURRENT GA Reference Doc.
3.0.4-SNAPSHOT SNAPSHOT Reference Doc.
2.2.9.RELEASE GA Reference Doc.


Designed to be completed in 15-30 minutes, a guide provides quick, hands-on instructions for building a starter app for any development task with Spring.