StripPrefix
GatewayFilter
Factory
StripPrefix
GatewayFilter
工厂采用一个参数 parts
。parts
参数指示在将请求发往下游之前要从路径中移除的部分数。以下清单配置 StripPrefix
GatewayFilter
:
The StripPrefix
GatewayFilter
factory takes one parameter, parts
.
The parts
parameter indicates the number of parts in the path to strip from the request before sending it downstream.
The following listing configures a StripPrefix
GatewayFilter
:
application.yml
spring:
cloud:
gateway:
routes:
- id: nameRoot
uri: https://nameservice
predicates:
- Path=/name/**
filters:
- StripPrefix=2
当通过网关向 /name/blue/red
发出请求时,向 nameService
发出的请求看上去就像 https://nameservice/red
。
When a request is made through the gateway to /name/blue/red
, the request made to nameservice
looks like https://nameservice/red
.