sping cloud微服务中zuul路由

不论是使用传统路由的配置方式还是服务路由的配置方式,我们都需要为每个路由规则定义匹配表达式;

     ? 匹配任意的单个字符   URL路径 /user-service/?    匹配比如: /user-service/a 、 /user-service/b 、 /user-service/c

     *匹配任意数量的字符                   /user-service/*                        /user-service/a 、 /user-service/abc 、 /user-service/efg 。但是它无法匹配 /user-service/a/b

     **匹配任意数量的字符,支持多级目录                                        /user-service/a/b 

      如果我们不希望 /hello 接口被路由::

              zuul.ignored-patterns=/**/hello/**

              zuul.routes.api-a.path=/api-a/**

              zuul.routes.api-a.serviceId=hello-service

      实际配置  zuul:
                         routes:
                            user-service:
                                  path: /basic/**
                                  service-id: channel-basic-service
                           order-service:
                                  path: /order-service/**
                                  service-id: channel-order-service

     通过网关来访问 hello-service 的 /hello 接口: http://localhost:8888/api-a/hello

原文地址:https://www.cnblogs.com/tianlifitting/p/8572523.html