I not found this document and code example , can you give me some document to do this? to replace my zuul ,?
let me try answering your question:
spring.cloud.gateway:
routes:
- id: test
uri: lb://service-id-on-eureka/foo/bar
predicates:
- Path=/foo/bar
That's all you need to do.
@dongzhuming 您好,请问我必须配置routes吗?而不能像zuul一样,配置注册中心就可以了吗?因为zuul可以自动读取注册中心的服务并且自动生成路由
For Spring Cloud Gateway, Spring Cloud Config is already supported and out-of-box. You can set them in bootstrap.yml as a normal Spring Cloud applications do.
@zxj19951029 you can try the following config in application.yml:
spring:
cloud:
gateway:
discovery.locator:
enabled: true
lowerCaseServiceId: true
@dongzhuming
https://github.com/spring-cloud/spring-cloud-gateway/issues/501
java config seems don't work
let me try answering your question:
- introduce dependency of spring-cloud-starter-netflix-eureka-client
- build-up a bootstrap.yml as a normal eureka client do
- in application.yml, you can configure a route like this code
spring.cloud.gateway: routes: - id: test uri: lb://service-id-on-eureka/foo/bar predicates: - Path=/foo/barThat's all you need to do.
IMO this should be detailed in the docs, as it's not immediately obvious
@chriswhite199 we always accept PRs to enhance our docs :)
@
let me try answering your question:
- introduce dependency of spring-cloud-starter-netflix-eureka-client
- build-up a bootstrap.yml as a normal eureka client do
- in application.yml, you can configure a route like this code
spring.cloud.gateway: routes: - id: test uri: lb://service-id-on-eureka/foo/bar predicates: - Path=/foo/barThat's all you need to do.
IMO this should be detailed in the docs, as it's not immediately obvious
After setting this up, how can I call the service from gateway
is it http://my-cloud-gateway-route/test/foo/bar
Please help me with this. Also, can the Path predicate take wildcards with just service id on eureka in the uri part so that all/group endpoints can be configured in single step ?
Yes should be
Also, can the Path predicate take wildcards with just service id on eureka in the uri part so that all/group endpoints can be configured in single step ?
Maybe it depends on what the underlying load balancer is.
If you have further questions please open a separate issue with an example we can reference.
Closing due to age of the question. If you would like us to look at this issue, please comment and we will look at re-opening the issue.
spring-cloud-gateway and eureka service works fine when i deploy the services on-prem.
But when I deploy
spring cloud gateway app for routing
eureka server
route API on cloud
service name does not get resolved
both my gatewayApp and route API are successfully registered to eureka server
SpringBoot- 2.1.6.RELEASE
and Greenwhich.SR1 dependency is used
Most helpful comment
let me try answering your question:
That's all you need to do.