根据请求mark做请求转发,实现灰度功能
experimental:plugins:requst-dispatch:moduleName: github.com/qxsugar/request-dispatchversion: v1.0.1
http:routers:api:rule: host(`api.test.cn`)service: svcentryPoints:- webmiddlewares:- requst-dispatchservices:svc:loadBalancer:servers:- url: "http://prod.api.cn"middlewares:requst-dispatch:plugin:requst-dispatch:logLevel: DEBUGmarkHeader: X-TagmarkHosts:alpha:- http://alpha.api.cn- http://alpha1.api.cnbeta:- http://beta.api.cn
如果请求头带有markHeader的参数,请求将会被分发到对应的地址
http api.test.cn X-Tag:alpha -v # 请求会被分发到
http://alpha.api.cn
或http://alpha1.api.cn
http api.test.cn X-Tag:beta -v # 请求会被转分发到
http://beta.api.cn
http api.test.cn X-Tag:whoami -v # 请求不会被分发