简体   繁体   中英

Cannot work api request in Spring Cloud API Gateway

I have a problem about running the URLs shown below.

http://localhost:8041/users-ws/users/status/check (run)
http://localhost:8041/users/status/check (not run)

What I want to do is to run all these URL but only the first one runs. How can I run both URLs? How can I revise application properties file?

Here is my code snippet shown below in application.properties file in Spring Cloud API Gateway

server.port=8041
spring.application.name=api-gateway
eureka.client.service-url.defaultZone=http://localhost:8040/eureka

spring.cloud.gateway.routes[0].id=users-status-check
spring.cloud.gateway.routes[0].uri = lb://users-ws
spring.cloud.gateway.routes[0].predicates[0]=Path=/users-ws/users/status/check
spring.cloud.gateway.routes[0].predicates[1]=Method=GET
spring.cloud.gateway.routes[0].filters[0]=RemoveRequestHeader=Cookie
spring.cloud.gateway.routes[0].filters[1]=RewritePath=/users-ws/(?<segment>.*), /$\{segment}

Could you post your user-ws controller? Anyway, try that:

spring.cloud.gateway.routes[0].predicates[0]=Path=/users/**

looks like your application name is "users-ws", and your request mapping is "/users", in this case, is not necessary put your application name in the path but we need to see more code, to be honest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM