Skip to content

Instantly share code, notes, and snippets.

@AdrianoJS
Created April 12, 2023 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdrianoJS/8f0285416ea975fe01d40f9718f1955c to your computer and use it in GitHub Desktop.
Save AdrianoJS/8f0285416ea975fe01d40f9718f1955c to your computer and use it in GitHub Desktop.
spring-cloud-gateway-example-stage-1-application.yaml
server:
port: 8080
app:
dependencies:
foo:
baseUrl: http://localhost:8081
bar:
baseUrl: http://localhost:8082
logging:
level:
root: info
no.embriq.api.gateway: debug
spring:
cloud:
gateway:
routes:
- id: "addition"
uri: ${app.dependencies.foo.baseUrl}
predicates:
# What triggers this route? In this case, it is requests sent to /api/add
- Path=/api/add
- id: "subtraction"
uri: ${app.dependencies.bar.baseUrl}
predicates:
- Path=/api/subtract
- id: "foo ping"
uri: ${app.dependencies.foo.baseUrl}
predicates:
- Path=/foo/ping
filters:
# Paths can be rewritten, e.g. when two internal applications have identical paths
# Syntax for RewritePath: https://cloud.spring.io/spring-cloud-gateway/reference/html/#the-rewritepath-gatewayfilter-factory
- RewritePath=/foo/ping,/api/ping
- id: "bar ping"
uri: ${app.dependencies.bar.baseUrl}
predicates:
- Path=/bar/ping
filters:
- RewritePath=/bar/ping,/api/ping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment