Class PredicateSpec
java.lang.Object
org.springframework.cloud.gateway.route.builder.UriSpec
org.springframework.cloud.gateway.route.builder.PredicateSpec
- Direct Known Subclasses:
BooleanSpec.BooleanOpSpec
Predicates that can be applied to a URI route.
-
Method Summary
Modifier and TypeMethodDescriptionafter(ZonedDateTime datetime) A predicate to check if a request was made after a specificZonedDateTime.A predicate which is always true.asyncPredicate(AsyncPredicate<org.springframework.web.server.ServerWebExchange> predicate) before(ZonedDateTime datetime) A predicate to check if a request was made before a specificZonedDateTime.between(ZonedDateTime datetime1, ZonedDateTime datetime2) A predicate to check if a request was made between twoZonedDateTimes.A predicate that checks if a cookie matches a given regular expression.protected GatewayFilterSpecA predicate that checks if a given header is present on the request.A predicate that checks if a given headers has a value which matches a regular expression.A predicate that checks if thehostheader matches a given pattern.A predicate that checks if the HTTP method matches.method(org.springframework.http.HttpMethod... methods) A predicate that checks if the HTTP method matches.not(Function<PredicateSpec, BooleanSpec> fn) order(int order) A predicate that checks if the path of the request matches the given pattern.A predicate that checks if the path of the request matches the given pattern.A predicate that checks if a given query parameter is present in the request URL.A predicate that checks if a query parameter matches a regular expression.A predicate that checks if a query parameter value matches criteria of a given predicate.<T> BooleanSpecThis predicate is BETA and may be subject to change in a future release.remoteAddr(String... addrs) A predicate which checks the remote address of the request.remoteAddr(@Nullable RemoteAddressResolver resolver, String... addrs) A predicate which checks the remote address of the request.A predicate that checks for the version specified.A predicate which will select a route based on its assigned weight.xForwardedRemoteAddr(String... addrs) A predicate which checks the remote address of the request based off of theX-Forwarded-Forheader.
-
Method Details
-
order
-
predicate
-
asyncPredicate
public BooleanSpec asyncPredicate(AsyncPredicate<org.springframework.web.server.ServerWebExchange> predicate) -
createGatewayFilterSpec
-
after
A predicate to check if a request was made after a specificZonedDateTime.- Parameters:
datetime- requests would only be routed after thisZonedDateTime- Returns:
- a
BooleanSpecto be used to add logical operators
-
before
A predicate to check if a request was made before a specificZonedDateTime.- Parameters:
datetime- requests will only be routed before thisZonedDateTime- Returns:
- a
BooleanSpecto be used to add logical operators
-
between
A predicate to check if a request was made between twoZonedDateTimes.- Parameters:
datetime1- the request must have been made after thisZonedDateTimedatetime2- the request must be made before thisZonedDateTime- Returns:
- a
BooleanSpecto be used to add logical operators
-
cookie
A predicate that checks if a cookie matches a given regular expression.- Parameters:
name- the name of the cookieregex- the value of the cookies will be evaluated against this regular expression- Returns:
- a
BooleanSpecto be used to add logical operators
-
header
A predicate that checks if a given header is present on the request.- Parameters:
header- the header name to check- Returns:
- a
BooleanSpecto be used to add logical operators
-
header
A predicate that checks if a given headers has a value which matches a regular expression.- Parameters:
header- the header name to checkregex- the regular expression to check against- Returns:
- a
BooleanSpecto be used to add logical operators
-
host
A predicate that checks if thehostheader matches a given pattern.- Parameters:
pattern- the pattern to check against. The pattern is an Ant style pattern with.as a separator- Returns:
- a
BooleanSpecto be used to add logical operators
-
method
A predicate that checks if the HTTP method matches.- Parameters:
methods- the name of the HTTP methods- Returns:
- a
BooleanSpecto be used to add logical operators
-
method
A predicate that checks if the HTTP method matches.- Parameters:
methods- the HTTP methods- Returns:
- a
BooleanSpecto be used to add logical operators
-
path
A predicate that checks if the path of the request matches the given pattern.- Parameters:
patterns- the pattern to check the path against. The pattern is aPathMatcherpattern- Returns:
- a
BooleanSpecto be used to add logical operators
-
path
A predicate that checks if the path of the request matches the given pattern.- Parameters:
matchTrailingSlash- set to false if you do not want this path to match when there is a trailing/patterns- the pattern to check the path against. The pattern is aPathMatcherpattern- Returns:
- a
BooleanSpecto be used to add logical operators
-
readBody
This predicate is BETA and may be subject to change in a future release. A predicate that checks the contents of the request body- Type Parameters:
T- the type the body is parsed to- Parameters:
inClass- the class to parse the body topredicate- a predicate to check the contents of the body- Returns:
- a
BooleanSpecto be used to add logical operators
-
query
A predicate that checks if a query parameter value matches criteria of a given predicate.- Parameters:
param- the query parameter namepredicate- a predicate to check the value of the param- Returns:
- a
BooleanSpecto be used to add logical operators
-
query
A predicate that checks if a query parameter matches a regular expression.- Parameters:
param- the query parameter nameregex- the regular expression to evaluate the query parameter value against- Returns:
- a
BooleanSpecto be used to add logical operators
-
query
A predicate that checks if a given query parameter is present in the request URL.- Parameters:
param- the query parameter name- Returns:
- a
BooleanSpecto be used to add logical operators
-
remoteAddr
A predicate which checks the remote address of the request. By default the RemoteAddr Route Predicate Factory uses the remote address from the incoming request. This may not match the actual client IP address if Spring Cloud Gateway sits behind a proxy layer. UseremoteAddr(RemoteAddressResolver, String...)to customize the resolver. You can customize the way that the remote address is resolved by setting a custom RemoteAddressResolver.- Parameters:
addrs- the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.- Returns:
- a
BooleanSpecto be used to add logical operators
-
remoteAddr
A predicate which checks the remote address of the request. Useful if Spring Cloud Gateway site behind a proxy layer. Spring Cloud Gateway comes with one non-default remote address resolver which is based off of theX-Forwarded-Forheader,XForwardedRemoteAddressResolver. SeeXForwardedRemoteAddressResolverfor more information.- Parameters:
resolver- theRemoteAddressResolverto use to resolve the remote IP address againstaddrs- the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.- Returns:
- a
BooleanSpecto be used to add logical operators
-
version
A predicate that checks for the version specified. This uses the Spring Framework ApiStrategry.- Parameters:
version- the version to check.- Returns:
- a
BooleanSpecto be used to add logical operators
-
xForwardedRemoteAddr
A predicate which checks the remote address of the request based off of theX-Forwarded-Forheader. Useful if Spring Cloud Gateway site behind a proxy layer. SeeXForwardedRemoteAddressResolverfor more information.- Parameters:
addrs- the remote address to verify. Should use CIDR-notation (IPv4 or IPv6) strings.- Returns:
- a
BooleanSpecto be used to add logical operators
-
weight
A predicate which will select a route based on its assigned weight.- Parameters:
group- the group the route belongs toweight- the weight for the route- Returns:
- a
BooleanSpecto be used to add logical operators
-
cloudFoundryRouteService
-
alwaysTrue
A predicate which is always true.- Returns:
- a
BooleanSpecto be used to add logical operators
-
not
-