How It Works

The following diagram provides a high-level overview of how Spring Cloud Gateway works:

Spring Cloud Gateway Server MVC Diagram

In Spring Cloud Gateway Server MVC routes are normal WebMvc.fn RouterFunction instances with a special HandlerFunction to forward the requests over HTTP defined in org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions. Please see the WebMvc.fn documentation for regular use of the functional API.

In addition to custom HandlerFunctions for HTTP forwarding, Spring Cloud Gateway Server MVC provides additional RequestPredicate implementations in org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates and HandlerFilterFunctions implementations in org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions. All the custom filters that can be pure 'before' filters are implemented in org.springframework.cloud.gateway.server.mvc.filter.BeforeFilterFunctions and adapted in FilterFunctions as request processors. The custom 'after' filters in org.springframework.cloud.gateway.server.mvc.filter.AfterFilterFunctions are also adapted in FilterFunctions as response processors.

There are additional *FilterFunctions classes for optional filters that will are documented along with each filter.

Any path defined on a route URI will be ignored.