public abstract class RequestPredicates extends 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(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(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(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(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(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(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(String pattern)
Return a
RequestPredicate that tests the request path
against the given path pattern. |
static RequestPredicate |
pathExtension(Predicate<String> extensionPredicate)
Return a
RequestPredicate that matches if the request's path matches the given
predicate. |
static RequestPredicate |
pathExtension(String extension)
Return a
RequestPredicate that matches if the request's path has the given extension. |
static Function<String,RequestPredicate> |
pathPredicates(PathPatternParser patternParser)
Return a function that creates new path-matching
RequestPredicates
from pattern Strings using the given PathPatternParser . |
static RequestPredicate |
POST(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(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(String name,
Predicate<String> predicate)
Return a
RequestPredicate that tests the request's query parameter of the given name
against the given predicate. |
static RequestPredicate |
queryParam(String name,
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(String pattern)
RequestPredicate
that tests the request path
against the given path pattern.pattern
- the pattern to match topublic static Function<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(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(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(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(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(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(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(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(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(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(Predicate<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(String name, 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(String name, Predicate<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)