Spring Cloud Gateway

Görkem AYKAÇ
2 min readSep 5, 2022

--

Gateway is one of most needed prerequisite for a project. Spring Cloud ecosystem has a cloud service called Spring Cloud Gateway. The Gateway works with Euraka. We can implement it easily and we can add some filter to our Gateway service like circuit breaker.

What is the Circuit Breaker?

Circuit Breaker filter can break requests on gateway level. For example we redirect request to related service with Gateway but service is not working. The service will throw exception but we want to break request if service is not available, because its safer.

1. How should create Gateway?

1.1. We have to add gateway dependency to related pom.xml

1.2. We have to add some annotations to related main class

1.3. We have to create FallBack methods for the circuit breaker filter

1.4. We have to create application.yml like this:

uri keyword is redirect request to related euraka instance

gateway can determine which requests will be forwarded with predicates keyword

we can add filter under the filters keyword

2. We Should Create a Service for the Example

2.1. We have to add euraka server dependency to related pom.xml

2.1. We have to add some annotations to main.class

2.2. We have to create controller class

2.3. We have to create application.yml like this:

Spring Cloud Gateway should work with Euraka Server. Gateway can redirect related requests to euraka clients so we created a service for the example.

It’s done. If you need euraka server you can read:

--

--

No responses yet