赞
踩
用来拦截访问路径,并发到uri
public class PathRoutePredicateFactory
extends AbstractRoutePredicateFactory<PathRoutePredicateFactory.Config>
{...}
路径多时,写在一行不便阅读,可以分开:
spring:
cloud:
gateway:
routes:
- id: my-route
uri: http://192.168.2.107
sensitiveHeaders: "*"
predicates:
- name: Path
args:
- /
- /index.htm
- /lib/**
- /module/**
- /handler/{segment}
6.25. The StripPrefix GatewayFilter Factory 接受一个参数 parts
。parts
参数表示在下行发送请求之前从请求中剥离的路径中的部件数量。官方例子:
spring:
cloud:
gateway:
routes:
- id: nameRoot
uri: https://nameservice
predicates:
- Path=/name/**
filters:
- StripPrefix=2
http://网关地址/name/blue/red
被网关拦截后/red
https://nameservice/red
路由规则 - 与其他章节在一页:5. Route Predicate Factories
路由规则 - 独立版:4. Route Predicate Factories - 4.8 Path Route Predicate Factory
Appendix A: Common application properties 常见属性
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。