Spring Cloud Gateway过滤器工厂GatewayFilterFactory初探

1. 概述

在【spring cloud gateway】的官方文档中,是这样说明GatewayFilterFactory的:

Route filters allow the modification of the incoming HTTP request or outgoing HTTP response in some manner. Route filters are scoped to a particular route. Spring Cloud Gateway includes many built-in GatewayFilter Factories.
  • 路由过滤器允许以某种方式修改传入的HTTP请求或传出的HTTP响应;
  • GatewayFilter不同于GlobalFilter,它只作用于指定的路由;
  • spring cloud gateway中内置了大量的网关过滤器工厂;

2. 分类

内置的过滤器工厂一共有22个,位于 org.springframework.cloud.gateway.filter.factoryorg.springframework.cloud.gateway.filter.factory.rewrite包中

2.1 根据用途划分

根据过滤器工厂的用途,可以划分为 HeaderParameterPathBodyStatusSessionRedirectRetryRateLimiterHystrix,具体如下:

  • Header

    • AddRequestHeaderGatewayFilterFactory
    • RemoveRequestHeaderGatewayFilterFactory
    • AddResponseHeaderGatewayFilterFactory
    • RemoveResponseHeaderGatewayFilterFactory
    • SetRequestHeaderGatewayFilterFactory
    • SetResponseHeaderGatewayFilterFactory
    • PreserveHostHeaderGatewayFilterFactory
    • RequestHeaderToRequestUriGatewayFilterFactory
    • SecureHeadersGatewayFilterFactory
  • Parameter

    • AddRequestParameterGatewayFilterFactory
  • Path

    • PrefixPathGatewayFilterFactory
    • RewritePathGatewayFilterFactory
    • SetPathGatewayFilterFactory
    • StripPrefixGatewayFilterFactory
  • Body

    • ModifyRequestBodyGatewayFilterFactory
    • ModifyResponseBodyGatewayFilterFactory
  • Status

    • SetStatusGatewayFilterFactory
  • Session

    • SaveSessionGatewayFilterFactory
  • Redirect

    • RedirectToGatewayFilterFactory
  • Retry

    • RetryGatewayFilterFactory
  • RateLimiter

    • RequestRateLimiterGatewayFilterFactory
  • Hystrix

    • HystrixGatewayFilterFactory

2.2 根据作用域划分

根据过滤器工厂的作用域划分,主要分为两类,一类是作用于 request,另一类是作用于 response,具体如下:

  • Request

    • AddRequestHeaderGatewayFilterFactory
    • RemoveRequestHeaderGatewayFilterFactory
    • SetRequestHeaderGatewayFilterFactory
    • PreserveHostHeaderGatewayFilterFactory
    • RequestHeaderToRequestUriGatewayFilterFactory
    • AddRequestParameterGatewayFilterFactory
    • PrefixPathGatewayFilterFactory
    • RewritePathGatewayFilterFactory
    • SetPathGatewayFilterFactory
    • StripPrefixGatewayFilterFactory
    • ModifyRequestBodyGatewayFilterFactory
    • SaveSessionGatewayFilterFactory
    • RequestRateLimiterGatewayFilterFactory
    • HystrixGatewayFilterFactory
  • Response

    • AddResponseHeaderGatewayFilterFactory
    • RemoveResponseHeaderGatewayFilterFactory
    • SetResponseHeaderGatewayFilterFactory
    • SecureHeadersGatewayFilterFactory
    • ModifyResponseBodyGatewayFilterFactory
    • SetStatusGatewayFilterFactory
    • RedirectToGatewayFilterFactory
    • RetryGatewayFilterFactory

你可能感兴趣的:(gateway,spring-cloud)