path路由断言工厂
- id: pathInfo
uri: http://www.example.com/
predicates:
- Path=/abcd/{segment}
query路由断言工厂
- id: queryInfo
uri: http://www.example.com/
predicates:
- Query= foo,bb
method路由断言工厂`
- id: methodnfo
uri: http://www.example.com/
predicates:
- Method= DELETE
curl --location --request DELETE 'http://127.0.0.1:10011/adfasfsdfdsd'
head 路由断言工厂
- id: headinfo
uri: http://www.example.com/
predicates:
- Header=x-ragnar-traceid,[\w\d]+
curl --location --request GET 'http://127.0.0.1:10011/adfasfsdfdsd12312' \
--header 'x-ragnar-traceid: 123213123'
自定义路由断言工厂
自定义断言工厂代码
@Slf4j
@Component
public class GrayRoutePredicateFactory extends AbstractRoutePredicateFactory<GrayCfg> {
public GrayRoutePredicateFactory() {
super(GrayCfg.class);
}
@Override
public Predicate<ServerWebExchange> apply(GrayCfg cfg) {
return serverWebExchange -> {
log.info("enter GrayRoutePredicateFactory"+cfg.isGrayStatus());
if (cfg.isGrayStatus()) {
log.info(" GrayRoutePredicateFactory hit start gray");
return true;
}
return false;
};
}
}
自定义断言工厂配置
- id: grayinfo
uri: http://www.baidu.com/
predicates:
- Path=/eee/**
- name: Gray
args:
grayStatus: true
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。