public abstract class RequestPredicates
extends java.lang.Object
RequestPredicate
that implement various useful
request matching operations, such as matching based on path, HTTP method, etc.Constructor and Description |
---|
RequestPredicates() |
Modifier and Type | Method and Description |
---|---|
static RequestPredicate |
accept(MediaType... mediaTypes)
Return a
RequestPredicate that tests if the request's
accept header is
compatible with any of the given media types. |
static RequestPredicate |
all()
Return a
RequestPredicate that always matches. |
static RequestPredicate |
contentType(MediaType... mediaTypes)
Return a
RequestPredicate that tests if the request's
content type is
included by any of the given media types. |
static RequestPredicate |
DELETE(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is DELETE
and the given pattern matches against the request path. |
static RequestPredicate |
GET(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is GET
and the given pattern matches against the request path. |
static RequestPredicate |
HEAD(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is HEAD
and the given pattern matches against the request path. |
static RequestPredicate |
headers(java.util.function.Predicate<ServerRequest.Headers> headersPredicate)
Return a
RequestPredicate that tests the request's headers
against the given headers predicate. |
static RequestPredicate |
method(HttpMethod httpMethod)
Return a
RequestPredicate that matches if the request's
HTTP method is equal to the given method. |
static RequestPredicate |
OPTIONS(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is OPTIONS
and the given pattern matches against the request path. |
static RequestPredicate |
PATCH(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is PATCH
and the given pattern matches against the request path. |
static RequestPredicate |
path(java.lang.String pattern)
Return a
RequestPredicate that tests the request path
against the given path pattern. |
static RequestPredicate |
pathExtension(java.util.function.Predicate<java.lang.String> extensionPredicate)
Return a
RequestPredicate that matches if the request's path matches the given
predicate. |
static RequestPredicate |
pathExtension(java.lang.String extension)
Return a
RequestPredicate that matches if the request's path has the given extension. |
static java.util.function.Function<java.lang.String,RequestPredicate> |
pathPredicates(PathPatternParser patternParser)
Return a function that creates new path-matching
RequestPredicates
from pattern Strings using the given PathPatternParser . |
static RequestPredicate |
POST(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is POST
and the given pattern matches against the request path. |
static RequestPredicate |
PUT(java.lang.String pattern)
Return a
RequestPredicate that matches if request's HTTP method is PUT
and the given pattern matches against the request path. |
static RequestPredicate |
queryParam(java.lang.String name,
java.util.function.Predicate<java.lang.String> predicate)
Return a
RequestPredicate that tests the request's query parameter of the given name
against the given predicate. |
static RequestPredicate |
queryParam(java.lang.String name,
java.lang.String value)
Return a
RequestPredicate that matches if the request's query parameter of the given name
has the given value. |
public static RequestPredicate all()
RequestPredicate
that always matches.public static RequestPredicate method(HttpMethod httpMethod)
RequestPredicate
that matches if the request's
HTTP method is equal to the given method.httpMethod
- the HTTP method to match againstpublic static RequestPredicate path(java.lang.String pattern)
RequestPredicate
that tests the request path
against the given path pattern.pattern
- the pattern to match topublic static java.util.function.Function<java.lang.String,RequestPredicate> pathPredicates(PathPatternParser patternParser)
RequestPredicates
from pattern Strings using the given PathPatternParser
.
This method can be used to specify a non-default, customized
PathPatternParser
when resolving path patterns.
patternParser
- the parser used to parse patterns given to the returned functionRequestPredicates
instancepublic static RequestPredicate headers(java.util.function.Predicate<ServerRequest.Headers> headersPredicate)
RequestPredicate
that tests the request's headers
against the given headers predicate.headersPredicate
- a predicate that tests against the request headerspublic static RequestPredicate contentType(MediaType... mediaTypes)
RequestPredicate
that tests if the request's
content type is
included by any of the given media types.mediaTypes
- the media types to match the request's content type againstpublic static RequestPredicate accept(MediaType... mediaTypes)
RequestPredicate
that tests if the request's
accept header is
compatible with any of the given media types.mediaTypes
- the media types to match the request's accept header againstpublic static RequestPredicate GET(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is GET
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate HEAD(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is HEAD
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate POST(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is POST
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate PUT(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is PUT
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate PATCH(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is PATCH
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate DELETE(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is DELETE
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate OPTIONS(java.lang.String pattern)
RequestPredicate
that matches if request's HTTP method is OPTIONS
and the given pattern
matches against the request path.pattern
- the path pattern to match againstpublic static RequestPredicate pathExtension(java.lang.String extension)
RequestPredicate
that matches if the request's path has the given extension.extension
- the path extension to match against, ignoring casepublic static RequestPredicate pathExtension(java.util.function.Predicate<java.lang.String> extensionPredicate)
RequestPredicate
that matches if the request's path matches the given
predicate.extensionPredicate
- the predicate to test against the request path extensionpublic static RequestPredicate queryParam(java.lang.String name, java.lang.String value)
RequestPredicate
that matches if the request's query parameter of the given name
has the given value.name
- the name of the query parameter to test againstvalue
- the value of the query parameter to test againstServerRequest.queryParam(String)
public static RequestPredicate queryParam(java.lang.String name, java.util.function.Predicate<java.lang.String> predicate)
RequestPredicate
that tests the request's query parameter of the given name
against the given predicate.name
- the name of the query parameter to test againstpredicate
- predicate to test against the query parameter valueServerRequest.queryParam(String)