我正在使用微服务体系结构构建Rest api。我为多个项目制作了多个apis用户。除了我无法将面向用户的url映射到zuul中的应用程序url之外,我还有其他一切准备就绪。Zuul URL映射与弹簧引导,尤里卡
面向url的用户是:user/v1/accountholders/{id}/cards,我的应用程序的实际url是/ user-cards/v1/accountholders/{id}/cards。
这里id是路径变量。下面是其他类似的API网址,所以如果有一种方法可以在zuul中进行一般配置。此外,应用程序url的上下文根也是Eureka中的项目名称。
Other similar urls are:
client side:- /user/v1/accountholders/{id}/cards/{cardid}
application:- /user-cards/v1/accountholders/{id}/cards/{cardid}
client side:- /user/v1/accountholders
application:- /user-cardholder/v1/accountholder
client side:- /user/v1/accountholders
application:- /user-cardholder/v1/accountholder
client side:- /user/v1/accountholders/{id}
application:- /user-cardholder/v1/accountholders/{id}
client side:- /user/v1/accountholders/{id}/accounts
application:- /user-accounts/v1/accountholders/{id}/accounts
client side:- /user/v1/accountholders/{id}/accounts/{accid}
application:- /user-accounts/v1/accountholders/{id}/accounts/{accid}
需要一些帮助在zuul的属性或yml文件中进行设置。我还没有能够在地图绘制方面取得任何进展。任何投入都将有所帮助。
解决: - 后正从@Daniel(这是公认的答案)输入这是我在zuul配置用于: -
zuul:
routes:
User-Cards:
path: /user/v1/accountholders/*/cards/**
url: http://desktop-uvkv1ed:9999/user-cards/v1/accountholders
User-Transactions1:
path: /user/v1/accountholders/*/transactions
url: http://desktop-uvkv1ed:5555/user-transactions/v1/accountholders
service-id: User-Transactions
User-Transactions2:
path: /user/v1/accountholders/*/accounts/*/transactions
url: http://desktop-uvkv1ed:5555/user-transactions/v1/accountholders
service-id: User-Transactions
User-Accounts:
path: /user/v1/accountholders/*/accounts/**
url: http://desktop-uvkv1ed:7777/user-accounts/v1/accountholders
User-Cardholders:
path: /user/v1/accountholders/**
url: http://desktop-uvkv1ed:8888/user-cardholders/v1/accountholders
乍一看,我不认为你想要的是现在可能的,尽管支持正则表达式映射的请求应该尽快登陆。 https://github.com/spring-cloud/spring-cloud-netflix/pull/699 – spencergibb
你能帮助我的方法,我可以使用我可以玩的应用程序的网址,但不是面向用户的网址,以便我可以轻松执行映射。 –
@spencergibb实际上,这可能是因为实质上所有可以追溯到支持蚂蚁式样匹配的'AbstractUrlMappingHandler'的子类。 –