public class GatewayFilterSpec extends UriSpec
Modifier and Type | Class and Description |
---|---|
class |
GatewayFilterSpec.RequestRateLimiterSpec |
Constructor and Description |
---|
GatewayFilterSpec(Route.AsyncBuilder routeBuilder,
RouteLocatorBuilder.Builder builder) |
Modifier and Type | Method and Description |
---|---|
GatewayFilterSpec |
addRequestHeader(String headerName,
String headerValue)
Adds a request header to the request before it is routed by the Gateway.
|
GatewayFilterSpec |
addRequestParameter(String param,
String value)
Adds a request parameter to the request before it is routed by the Gateway.
|
GatewayFilterSpec |
addResponseHeader(String headerName,
String headerValue)
Adds a header to the response returned to the Gateway from the route.
|
GatewayFilterSpec |
changeRequestUri(Function<org.springframework.web.server.ServerWebExchange,Optional<URI>> determineRequestUri)
A filter which change the URI the request will be routed to by the Gateway.
|
GatewayFilterSpec |
fallbackHeaders(Consumer<FallbackHeadersGatewayFilterFactory.Config> configConsumer)
Adds hystrix execution exception headers to fallback request.
|
GatewayFilterSpec |
fallbackHeaders(FallbackHeadersGatewayFilterFactory.Config config)
Adds hystrix execution exception headers to fallback request.
|
GatewayFilterSpec |
filter(GatewayFilter gatewayFilter)
Applies the filter to the route.
|
GatewayFilterSpec |
filter(GatewayFilter gatewayFilter,
int order)
Applies the filter to the route.
|
GatewayFilterSpec |
filters(Collection<GatewayFilter> gatewayFilters)
Applies the list of filters to the route.
|
GatewayFilterSpec |
filters(GatewayFilter... gatewayFilters)
Applies the list of filters to the route.
|
GatewayFilterSpec |
hystrix(Consumer<HystrixGatewayFilterFactory.Config> configConsumer)
Wraps the route in a Hystrix command.
|
<T,R> GatewayFilterSpec |
modifyRequestBody(Class<T> inClass,
Class<R> outClass,
RewriteFunction<T,R> rewriteFunction)
A filter that can be used to modify the request body.
|
<T,R> GatewayFilterSpec |
modifyRequestBody(Class<T> inClass,
Class<R> outClass,
String newContentType,
RewriteFunction<T,R> rewriteFunction)
A filter that can be used to modify the request body.
|
<T,R> GatewayFilterSpec |
modifyResponseBody(Class<T> inClass,
Class<R> outClass,
RewriteFunction<T,R> rewriteFunction)
A filter that can be used to modify the response body
This filter is BETA and may be subject to change in a future release.
|
<T,R> GatewayFilterSpec |
modifyResponseBody(Class<T> inClass,
Class<R> outClass,
String newContentType,
RewriteFunction<T,R> rewriteFunction)
A filter that can be used to modify the response body
This filter is BETA and may be subject to change in a future release.
|
GatewayFilterSpec |
prefixPath(String prefix)
A filter that can be used to add a prefix to the path of a request before it is routed by the Gateway.
|
GatewayFilterSpec |
preserveHostHeader()
A filter that will preserve the host header of the request on the outgoing request from the Gateway.
|
GatewayFilterSpec |
redirect(org.springframework.http.HttpStatus status,
URL url)
A filter that will return a redirect response back to the client.
|
GatewayFilterSpec |
redirect(int status,
String url)
A filter that will return a redirect response back to the client.
|
GatewayFilterSpec |
redirect(int status,
URI url)
A filter that will return a redirect response back to the client.
|
GatewayFilterSpec |
redirect(String status,
String url)
A filter that will return a redirect response back to the client.
|
GatewayFilterSpec |
redirect(String status,
URI url)
A filter that will return a redirect response back to the client.
|
GatewayFilterSpec |
removeRequestHeader(String headerName)
A filter that will remove a request header before the request is routed by the Gateway.
|
GatewayFilterSpec |
removeResponseHeader(String headerName)
A filter that will remove a response header before the Gateway returns the response to the client.
|
GatewayFilterSpec |
requestHeaderToRequestUri(String headerName)
A filter which changes the URI the request will be routed to by the Gateway by pulling it from a header on the
request.
|
GatewayFilterSpec.RequestRateLimiterSpec |
requestRateLimiter()
A filter that will set up a request rate limiter for a route.
|
GatewayFilterSpec |
requestRateLimiter(Consumer<RequestRateLimiterGatewayFilterFactory.Config> configConsumer)
A filter that will set up a request rate limiter for a route.
|
GatewayFilterSpec |
retry(Consumer<RetryGatewayFilterFactory.RetryConfig> retryConsumer)
A filter that will retry failed requests.
|
GatewayFilterSpec |
retry(int retries)
A filter that will retry failed requests.
|
GatewayFilterSpec |
retry(reactor.retry.Repeat<org.springframework.web.server.ServerWebExchange> repeat,
reactor.retry.Retry<org.springframework.web.server.ServerWebExchange> retry)
A filter that will retry failed requests.
|
GatewayFilterSpec |
rewritePath(String regex,
String replacement)
A filter which rewrites the request path before it is routed by the Gateway
|
GatewayFilterSpec |
rewriteResponseHeader(String headerName,
String regex,
String replacement)
A filter that rewrites a header value on the response before it is returned to the client by the Gateway.
|
GatewayFilterSpec |
saveSession()
A filter which forces a
WebSession::save operation before forwarding the call downstream. |
GatewayFilterSpec |
secureHeaders()
A filter that adds a number of headers to the response at the reccomendation from
this blog post.
|
GatewayFilterSpec |
setPath(String template)
A filter that sets the path of the request before it is routed by the Gateway.
|
GatewayFilterSpec |
setRequestHeader(String headerName,
String headerValue)
A filter that sets a header on the request before it is routed by the Gateway.
|
GatewayFilterSpec |
setRequestSize(Long size)
A filter that sets the maximum permissible size of a Request.
|
GatewayFilterSpec |
setResponseHeader(String headerName,
String headerValue)
A filter that sets a header on the response before it is returned to the client by the Gateway.
|
GatewayFilterSpec |
setStatus(org.springframework.http.HttpStatus status)
A filter that sets the status on the response before it is returned to the client by the Gateway.
|
GatewayFilterSpec |
setStatus(int status)
A filter that sets the status on the response before it is returned to the client by the Gateway.
|
GatewayFilterSpec |
setStatus(String status)
A filter that sets the status on the response before it is returned to the client by the Gateway.
|
GatewayFilterSpec |
stripPrefix(int parts)
Strips the prefix from the path of the request before it is routed by the Gateway.
|
List<GatewayFilter> |
transformToOrderedFilters(Stream<GatewayFilter> stream) |
public GatewayFilterSpec(Route.AsyncBuilder routeBuilder, RouteLocatorBuilder.Builder builder)
public GatewayFilterSpec filter(GatewayFilter gatewayFilter)
gatewayFilter
- the filter to applyGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec filter(GatewayFilter gatewayFilter, int order)
gatewayFilter
- the filter to applyorder
- the order to apply the filterGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec filters(GatewayFilter... gatewayFilters)
gatewayFilters
- the filters to applyGatewayFilterSpec
that can be used to apply additional filterspublic List<GatewayFilter> transformToOrderedFilters(Stream<GatewayFilter> stream)
public GatewayFilterSpec filters(Collection<GatewayFilter> gatewayFilters)
gatewayFilters
- the filters to applyGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec addRequestHeader(String headerName, String headerValue)
headerName
- the header nameheaderValue
- the header valueGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec addRequestParameter(String param, String value)
param
- the parameter namevalue
- the parameter vauleGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec addResponseHeader(String headerName, String headerValue)
headerName
- the header nameheaderValue
- the header valueGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec hystrix(Consumer<HystrixGatewayFilterFactory.Config> configConsumer)
http://cloud.spring.io/spring-cloud-netflix/
configConsumer
- a Consumer
which provides configuration for the Hystrix commandGatewayFilterSpec
that can be used to apply additional filterspublic <T,R> GatewayFilterSpec modifyRequestBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T,R> rewriteFunction)
T
- the original request body classR
- the new request body classinClass
- the class to convert the incoming request body tooutClass
- the class the Gateway will add to the request before it is routedrewriteFunction
- the RewriteFunction
that transforms the request bodyGatewayFilterSpec
that can be used to apply additional filterspublic <T,R> GatewayFilterSpec modifyRequestBody(Class<T> inClass, Class<R> outClass, String newContentType, RewriteFunction<T,R> rewriteFunction)
T
- the original request body classR
- the new request body classinClass
- the class to convert the incoming request body tooutClass
- the class the Gateway will add to the request before it is routednewContentType
- the new Content-Type header to be sentrewriteFunction
- the RewriteFunction
that transforms the request bodyGatewayFilterSpec
that can be used to apply additional filterspublic <T,R> GatewayFilterSpec modifyResponseBody(Class<T> inClass, Class<R> outClass, RewriteFunction<T,R> rewriteFunction)
T
- the original response body classR
- the new response body classinClass
- the class to conver the response body tooutClass
- the class the Gateway will add to the response before it is returned to the clientrewriteFunction
- the RewriteFunction
that transforms the response bodyGatewayFilterSpec
that can be used to apply additional filterspublic <T,R> GatewayFilterSpec modifyResponseBody(Class<T> inClass, Class<R> outClass, String newContentType, RewriteFunction<T,R> rewriteFunction)
T
- the original response body classR
- the new response body classinClass
- the class to conver the response body tooutClass
- the class the Gateway will add to the response before it is returned to the clientnewContentType
- the new Content-Type header to be returnedrewriteFunction
- the RewriteFunction
that transforms the response bodyGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec prefixPath(String prefix)
prefix
- the prefix to add to the pathGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec preserveHostHeader()
GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec redirect(int status, URI url)
status
- an HTTP status code, should be a 300
series redirecturl
- the URL to redirect to. This URL will be set in the location
headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec redirect(int status, String url)
status
- an HTTP status code, should be a 300
series redirecturl
- the URL to redirect to. This URL will be set in the location
headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec redirect(String status, URI url)
status
- an HTTP status code, should be a 300
series redirecturl
- the URL to redirect to. This URL will be set in the location
headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec redirect(String status, String url)
status
- an HTTP status code, should be a 300
series redirecturl
- the URL to redirect to. This URL will be set in the location
headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec redirect(org.springframework.http.HttpStatus status, URL url)
status
- an HTTP status code, should be a 300
series redirecturl
- the URL to redirect to. This URL will be set in the location
headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec removeRequestHeader(String headerName)
headerName
- the name of the header to removeGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec removeResponseHeader(String headerName)
headerName
- the name of the header to removeGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec requestRateLimiter(Consumer<RequestRateLimiterGatewayFilterFactory.Config> configConsumer)
configConsumer
- a Consumer
that will return configuration for the rate limiterGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec.RequestRateLimiterSpec requestRateLimiter()
GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec rewritePath(String regex, String replacement)
regex
- a Java regular expression to match the path againstreplacement
- the replacement for the pathGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec retry(int retries)
5xx
errors and GET
s are retryable.retries
- max number of retriesGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec retry(Consumer<RetryGatewayFilterFactory.RetryConfig> retryConsumer)
retryConsumer
- a Consumer
which returns a RetryGatewayFilterFactory.RetryConfig
to configure the retry functionalityGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec retry(reactor.retry.Repeat<org.springframework.web.server.ServerWebExchange> repeat, reactor.retry.Retry<org.springframework.web.server.ServerWebExchange> retry)
repeat
- a Repeat
retry
- a Retry
GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec secureHeaders()
GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setPath(String template)
template
- the path to set on the request, allows multiple matching segments using URI templates from
Spring FrameworkGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setRequestHeader(String headerName, String headerValue)
headerName
- the header nameheaderValue
- the value of the headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setResponseHeader(String headerName, String headerValue)
headerName
- the header nameheaderValue
- the value of the headerGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec rewriteResponseHeader(String headerName, String regex, String replacement)
headerName
- the header nameregex
- a Java regular expression to match the path againstreplacement
- the replacement for the pathGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setStatus(int status)
status
- the status to set on the responseGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setStatus(org.springframework.http.HttpStatus status)
status
- the status to set on the responseGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setStatus(String status)
status
- the status to set on the responseGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec saveSession()
WebSession::save
operation before forwarding the call downstream. This is of
particular use when using something like Spring Session
with a lazy data store and need to ensure the session state has been saved before making the forwarded call.
If you are integrating Spring Security with
Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec stripPrefix(int parts)
parts
- the number of parts of the path to removeGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec requestHeaderToRequestUri(String headerName)
headerName
- the header name containing the URIGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec changeRequestUri(Function<org.springframework.web.server.ServerWebExchange,Optional<URI>> determineRequestUri)
determineRequestUri
- a Function
which takes a ServerWebExchange
and returns a URI to
route the request toGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec setRequestSize(Long size)
size
- the maximum size of a requestGatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec fallbackHeaders(FallbackHeadersGatewayFilterFactory.Config config)
http://cloud.spring.io/spring-cloud-netflix/
config
- a FallbackHeadersGatewayFilterFactory.Config
which provides the header names.
If header names arguments are not provided, default values are used.GatewayFilterSpec
that can be used to apply additional filterspublic GatewayFilterSpec fallbackHeaders(Consumer<FallbackHeadersGatewayFilterFactory.Config> configConsumer)
http://cloud.spring.io/spring-cloud-netflix/
configConsumer
- a Consumer
which can be used to set up the names of the headers in the config.
If header names arguments are not provided, default values are used.GatewayFilterSpec
that can be used to apply additional filtersCopyright © 2019 Pivotal Software, Inc.. All rights reserved.