Mention PathPattern in functional router Javadoc

This commit makes the various supported patterns
more discoverable.

Closes gh-32045
This commit is contained in:
Sébastien Deleuze
2024-01-17 15:08:34 +01:00
parent 0ada78ad84
commit 5dd48fc068
4 changed files with 60 additions and 0 deletions

View File

@@ -107,6 +107,7 @@ public abstract class RequestPredicates {
* against the given path pattern.
* @param pattern the pattern to match to
* @return a predicate that tests against the given path pattern
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate path(String pattern) {
Assert.notNull(pattern, "'pattern' must not be null");
@@ -169,6 +170,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is GET and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate GET(String pattern) {
return method(HttpMethod.GET).and(path(pattern));
@@ -180,6 +182,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is HEAD and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate HEAD(String pattern) {
return method(HttpMethod.HEAD).and(path(pattern));
@@ -191,6 +194,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is POST and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate POST(String pattern) {
return method(HttpMethod.POST).and(path(pattern));
@@ -202,6 +206,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is PUT and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate PUT(String pattern) {
return method(HttpMethod.PUT).and(path(pattern));
@@ -213,6 +218,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is PATCH and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate PATCH(String pattern) {
return method(HttpMethod.PATCH).and(path(pattern));
@@ -224,6 +230,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is DELETE and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate DELETE(String pattern) {
return method(HttpMethod.DELETE).and(path(pattern));
@@ -235,6 +242,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is OPTIONS and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate OPTIONS(String pattern) {
return method(HttpMethod.OPTIONS).and(path(pattern));
@@ -342,6 +350,7 @@ public abstract class RequestPredicates {
* Receive notification of a path predicate.
* @param pattern the path pattern that makes up the predicate
* @see RequestPredicates#path(String)
* @see org.springframework.web.util.pattern.PathPattern
*/
void path(String pattern);

View File

@@ -155,6 +155,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return a router function that routes to resources
* @see org.springframework.web.util.pattern.PathPattern
* @see #resourceLookupFunction(String, Resource)
*/
public static RouterFunction<ServerResponse> resources(String pattern, Resource location) {
@@ -173,6 +174,7 @@ public abstract class RouterFunctions {
* @param headersConsumer provides access to the HTTP headers for served resources
* @return a router function that routes to resources
* @since 6.1
* @see org.springframework.web.util.pattern.PathPattern
* @see #resourceLookupFunction(String, Resource)
*/
public static RouterFunction<ServerResponse> resources(String pattern, Resource location,
@@ -194,6 +196,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return the default resource lookup function for the given parameters.
* @see org.springframework.web.util.pattern.PathPattern
*/
public static Function<ServerRequest, Mono<Resource>> resourceLookupFunction(String pattern, Resource location) {
return new PathResourceLookupFunction(pattern, location);
@@ -338,6 +341,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code GET} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -369,6 +373,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code GET} requests that
* match {@code pattern} and the predicate
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
* @see RequestPredicates
*/
Builder GET(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -388,6 +393,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code HEAD} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -411,6 +417,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code HEAD} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -429,6 +436,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code POST} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -460,6 +468,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code POST} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -478,6 +487,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PUT} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -509,6 +519,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PUT} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -527,6 +538,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PATCH} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -558,6 +570,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PATCH} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -576,6 +589,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code DELETE} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -599,6 +613,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code DELETE} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -617,6 +632,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -640,6 +656,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -685,6 +702,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder resources(String pattern, Resource location);
@@ -700,6 +718,7 @@ public abstract class RouterFunctions {
* @param headersConsumer provides access to the HTTP headers for served resources
* @return this builder
* @since 6.1
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder resources(String pattern, Resource location, BiConsumer<Resource, HttpHeaders> headersConsumer);
@@ -790,6 +809,7 @@ public abstract class RouterFunctions {
* @param routerFunctionSupplier supplier for the nested router function to delegate to if
* the pattern matches
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder path(String pattern, Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier);
@@ -812,6 +832,7 @@ public abstract class RouterFunctions {
* @param builderConsumer consumer for a {@code Builder} that provides the nested router
* function
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder path(String pattern, Consumer<Builder> builderConsumer);

View File

@@ -107,6 +107,7 @@ public abstract class RequestPredicates {
* against the given path pattern.
* @param pattern the pattern to match to
* @return a predicate that tests against the given path pattern
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate path(String pattern) {
Assert.notNull(pattern, "'pattern' must not be null");
@@ -169,6 +170,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is GET and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate GET(String pattern) {
return method(HttpMethod.GET).and(path(pattern));
@@ -180,6 +182,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is HEAD and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate HEAD(String pattern) {
return method(HttpMethod.HEAD).and(path(pattern));
@@ -191,6 +194,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is POST and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate POST(String pattern) {
return method(HttpMethod.POST).and(path(pattern));
@@ -202,6 +206,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is PUT and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate PUT(String pattern) {
return method(HttpMethod.PUT).and(path(pattern));
@@ -213,6 +218,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is PATCH and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate PATCH(String pattern) {
return method(HttpMethod.PATCH).and(path(pattern));
@@ -224,6 +230,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is DELETE and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate DELETE(String pattern) {
return method(HttpMethod.DELETE).and(path(pattern));
@@ -235,6 +242,7 @@ public abstract class RequestPredicates {
* @param pattern the path pattern to match against
* @return a predicate that matches if the request method is OPTIONS and if the given pattern
* matches against the request path
* @see org.springframework.web.util.pattern.PathPattern
*/
public static RequestPredicate OPTIONS(String pattern) {
return method(HttpMethod.OPTIONS).and(path(pattern));
@@ -341,6 +349,7 @@ public abstract class RequestPredicates {
* Receive notification of a path predicate.
* @param pattern the path pattern that makes up the predicate
* @see RequestPredicates#path(String)
* @see org.springframework.web.util.pattern.PathPattern
*/
void path(String pattern);

View File

@@ -138,6 +138,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return a router function that routes to resources
* @see org.springframework.web.util.pattern.PathPattern
* @see #resourceLookupFunction(String, Resource)
*/
public static RouterFunction<ServerResponse> resources(String pattern, Resource location) {
@@ -156,6 +157,7 @@ public abstract class RouterFunctions {
* @param headersConsumer provides access to the HTTP headers for served resources
* @return a router function that routes to resources
* @since 6.1
* @see org.springframework.web.util.pattern.PathPattern
* @see #resourceLookupFunction(String, Resource)
*/
public static RouterFunction<ServerResponse> resources(String pattern, Resource location,
@@ -177,6 +179,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return the default resource lookup function for the given parameters.
* @see org.springframework.web.util.pattern.PathPattern
*/
public static Function<ServerRequest, Optional<Resource>> resourceLookupFunction(String pattern, Resource location) {
return new PathResourceLookupFunction(pattern, location);
@@ -249,6 +252,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code GET} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -280,6 +284,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code GET} requests that
* match {@code pattern} and the predicate
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
* @see RequestPredicates
*/
Builder GET(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -299,6 +304,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code HEAD} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -322,6 +328,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code HEAD} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -340,6 +347,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code POST} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -371,6 +379,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code POST} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -389,6 +398,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PUT} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -420,6 +430,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PUT} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -438,6 +449,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PATCH} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -469,6 +481,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code PATCH} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -487,6 +500,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code DELETE} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -510,6 +524,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code DELETE} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -528,6 +543,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction);
@@ -551,6 +567,7 @@ public abstract class RouterFunctions {
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests that
* match {@code pattern}
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
@@ -595,6 +612,7 @@ public abstract class RouterFunctions {
* @param pattern the pattern to match
* @param location the location directory relative to which resources should be resolved
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder resources(String pattern, Resource location);
@@ -610,6 +628,7 @@ public abstract class RouterFunctions {
* @param headersConsumer provides access to the HTTP headers for served resources
* @return this builder
* @since 6.1
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder resources(String pattern, Resource location, BiConsumer<Resource, HttpHeaders> headersConsumer);
@@ -700,6 +719,7 @@ public abstract class RouterFunctions {
* @param routerFunctionSupplier supplier for the nested router function to delegate to if
* the pattern matches
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder path(String pattern, Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier);
@@ -722,6 +742,7 @@ public abstract class RouterFunctions {
* @param builderConsumer consumer for a {@code Builder} that provides the nested router
* function
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder path(String pattern, Consumer<Builder> builderConsumer);