cookie必须包含username=fox的时候才能请求通过,否则不让通过
spring:cloud:gateway:#设置路由:路由id、路由到微服务的uri、断言routes:- id: order_route #路由ID,全局唯一uri: http://localhost:8020 #目标微服务的请求地址和端口predicates:# Cookie匹配- Cookie=username, fox
代码地址
https://gitee.com/zjj19941/ZJJ_Neaten5.10/tree/master/ZJJ_Gateway/demo04
测试
yml配置:
routes:- id: order_route #路由ID,全局唯一,建议配合服务名# uri参数可以直接去指定ip端口,也可以指定负载均衡lb开头#uri: http://localhost:8020 #目标微服务的请求地址和端口uri: lb://mall-order #lb 整合负载均衡器ribbon,loadbalancerpredicates:# #Path路径匹配- Path=/order/**# Cookie匹配- Cookie=username, fox
完全匹配才能通过
没匹配就报404
完全没有也会报404
