引入依赖
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.cloud
spring-cloud-starter-gateway
自定义过滤器
可以继承 abstractgatewayfilterfactory 或实现 globalfilter 实现过滤请求功能
gatewayfilter
gatewayfilter 只能指定路径上应用
import org.springframework.cloud.gateway.filter.gatewayfilter;
import org.springframework.cloud.gateway.filter.factory.abstractgatewayfilterfactory;
import org.springframework.http.httpstatus;
import org.springframework.http.server.reactive.serverhttpresponse;
import org.springframework.stereotype.component;
@component
public class authgatewayfilterfactory extends abstractgatewayfilterfactory {
public authgatewayfilterfactory() {
super(config.class);
}
@override
public gatewayf