Skip to content

An example project that illustrates how to configure Spring Cloud Gateway app to add Connection header to all requests to downstream backend service.

Notifications You must be signed in to change notification settings

Antolius/spring-cloud-gateway-examples-headers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Cloud Gateway Headers Example

An example project that illustrates how to configure Spring Cloud Gateway app to add Connection header to all requests to downstream backend service.

Use-Case

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     |                         |            |
+--------+              +---------+                         +------------+
                                                                          

Getting Started

In case you wish to run the app yourself, feel free to clone the git repo and play around with it.

Prerequisites

The project uses:

Installing

Since this is a Maven project, you can install it with:

$ mvn clean install

Testing

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

Author

About

An example project that illustrates how to configure Spring Cloud Gateway app to add Connection header to all requests to downstream backend service.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages