Creating a custom Spring Cloud Gateway Filter
In this article, we look into writing a custom extension for Spring Cloud Gateway. Before we get started, let’s go over how Spring Cloud Gateway works:
- First, a client makes a network request to the Gateway
- The Gateway is defined with a number of routes, each with Predicates to match the request to the route. For example, you can match on the path segment of the URL or the HTTP method of the request.
- Once matched, the Gateway executes pre-request logic on each of the filters applied to the route. For example, you might want to add query parameters to your request
- A proxy filter routes the request to the proxied service
- The service executes and returns a response
- The gateway receives the response and executes post-request logic on each filter before returning the response. For example…