Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest Zuul路由到具有嵌套路径的服务_Rest_Spring Cloud_Netflix Zuul - Fatal编程技术网

Rest Zuul路由到具有嵌套路径的服务

Rest Zuul路由到具有嵌套路径的服务,rest,spring-cloud,netflix-zuul,Rest,Spring Cloud,Netflix Zuul,我正在尝试将Netflix Zuul路由配置为两个微服务(基于spring boot) 通过路径/foo/** 通过路径/foo/*/bar/** 我试过这样的方法,但没用: zuul: routes: foo: /foo/** bar: /foo/*/bar/** 当路径嵌套时,是否可能进行这种配置 需要这样的配置,因为/bar/子资源由bar微服务操作 foo上的上下文:/foo/ 条形图上的上下文:/foo/*/bar/**解决方案 zuul: routes:

我正在尝试将Netflix Zuul路由配置为两个微服务(基于spring boot)

  • 通过路径
    /foo/**
  • 通过路径
    /foo/*/bar/**
我试过这样的方法,但没用:

zuul:
  routes:
    foo: /foo/**
    bar: /foo/*/bar/**
当路径嵌套时,是否可能进行这种配置

需要这样的配置,因为
/bar/
子资源由bar微服务操作

foo上的上下文:
/foo/

条形图上的上下文:
/foo/*/bar/**
解决方案

zuul:
  routes:
    bar:
      path: /foo/*/bar/**
      serviceId: bar
      stripPrefix: false
    foo:
      path: /foo/**
      serviceId: foo
      stripPrefix: false

应该是这样的,但顺序很重要,在您当前的定义中,foo优先于bar。好的,但是经过更正的顺序仍然不起作用什么是“不起作用”?可能我收到了404的
GET/foo/X/bar/Y/action
,因为microservice bar希望收到
GET/foo/X/bar/Y/action
/foo/X/bar/Y/
被传递到bar?谢谢,它可以工作!:)