我使用jhipster-gateway创建了一对微型服务和一个https://start.jhipster.tech/#/。
在网关中,来自微服务的所有API都是可用的,但我需要在请求前缀中传递微服务名称。例如
http://localhost:8080/user-service/api/user
http://localhost:8080/pet-service/api/pets为此,我希望将其配置为不需要将服务名称传递到路径url中,如下所示
http://localhost:8080/api/user
http://localhost:8080/api/pets我尝试用zuul配置来修复它,如下所示
zuul:
sensitive-headers: Cookie,Set-Cookie
host:
max-total-connections: 1000
max-per-route-connections: 100
semaphore:
max-semaphores: 500
routes:
pets:
path: /api/pets/**
serviceId: pet-service
stripPrefix: true
users:
path: /api/user/**
serviceId: user-service
stripPrefix: true我从创始成员那里跟踪了这个演示。UW7pw
PS:我是新来的杰普斯特,并为我的下一个项目评估它。任何帮助都是非常感谢的。
发布于 2019-01-18 21:31:54
我认为您应该在zuul中设置前缀并设置路径映射。如下所示:
zuul.prefix=/api //define a path for the gateway
zuul.ignored-services=* //ignore services that mustn't exposed
zuul.routes.userService.path=/users/** //map of service
zuul.routes.userService.serviceId=user-service
zuul.routes.userService.path=/pets/**
zuul.routes.petService.serviceId=pet-service把我的答案写在属性上而不是yaml里。
https://stackoverflow.com/questions/54053386
复制相似问题