An example project that illustrates how to configure Spring Cloud Gateway app to add Connection header to all requests to downstream backend service.
The requirement of Spring Cloud Gateway app is to add a Connection: Keep-Alive header to all downstream requests, regardless of the upstream client request.
+--------+ +---------+ +------------+
| +------------->| Spring | Connection: keep-alive | Downstream |
| Client | | Cloud +------------------------>| Backend |
| | | Gateway |<------------------------+ Service |
| |<-------------+ App | | |
+--------+ +---------+ +------------+
In case you wish to run the app yourself, feel free to clone the git repo and play around with it.
The project uses:
Since this is a Maven project, you can install it with:
$ mvn clean install
In the test I use WireMock to simulate the downstream backend service and WebTestClient
to simulate the client. Test client makes HTTP requests to our app, which proxies them to WireMock server. At the end I assert that request made to WireMock server had Connection: keep-alive
header.
You can run tests with maven:
$ mvn test