Add no path HTTP method variants for route builder
This commit adds two overloaded methods for each HTTP method in the WebFlux.fn and WebMvc.fn route builders: one method taking just a handler function, the other a request predicate and handler function. After this commit, it is no longer required to provide a String path, which is particularly useful when nesting routes, and the path would be "". Closes gh-25752
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -36,9 +37,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
|
||||
private List<RouterFunction<ServerResponse>> routerFunctions = new ArrayList<>();
|
||||
private final List<RouterFunction<ServerResponse>> routerFunctions = new ArrayList<>();
|
||||
|
||||
private List<HandlerFilterFunction<ServerResponse, ServerResponse>> filterFunctions = new ArrayList<>();
|
||||
private final List<HandlerFilterFunction<ServerResponse, ServerResponse>> filterFunctions = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
@@ -48,13 +49,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return this;
|
||||
}
|
||||
|
||||
private RouterFunctions.Builder add(RequestPredicate predicate,
|
||||
HandlerFunction<ServerResponse> handlerFunction) {
|
||||
|
||||
private RouterFunctions.Builder add(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
this.routerFunctions.add(RouterFunctions.route(predicate, handlerFunction));
|
||||
return this;
|
||||
}
|
||||
|
||||
// GET
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder GET(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.GET), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder GET(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.GET).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.GET(pattern), handlerFunction);
|
||||
@@ -67,6 +78,18 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.GET(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// HEAD
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder HEAD(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.HEAD), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder HEAD(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.HEAD).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.HEAD(pattern), handlerFunction);
|
||||
@@ -79,6 +102,18 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.HEAD(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// POST
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder POST(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.POST), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder POST(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.POST).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.POST(pattern), handlerFunction);
|
||||
@@ -91,6 +126,18 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.POST(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// PUT
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PUT(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.PUT), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PUT(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.PUT).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.PUT(pattern), handlerFunction);
|
||||
@@ -103,6 +150,18 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.PUT(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// PATCH
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PATCH(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.PATCH), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PATCH(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.PATCH).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.PATCH(pattern), handlerFunction);
|
||||
@@ -115,6 +174,18 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.PATCH(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// DELETE
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder DELETE(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.DELETE), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder DELETE(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.DELETE).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.DELETE(pattern), handlerFunction);
|
||||
@@ -127,15 +198,21 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.DELETE(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// OPTIONS
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.OPTIONS(pattern), handlerFunction);
|
||||
public RouterFunctions.Builder OPTIONS(HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.OPTIONS), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder route(RequestPredicate predicate,
|
||||
HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RouterFunctions.route(predicate, handlerFunction));
|
||||
public RouterFunctions.Builder OPTIONS(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.method(HttpMethod.OPTIONS).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RequestPredicates.OPTIONS(pattern), handlerFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +222,14 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
|
||||
return add(RequestPredicates.OPTIONS(pattern).and(predicate), handlerFunction);
|
||||
}
|
||||
|
||||
// other
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder route(RequestPredicate predicate,
|
||||
HandlerFunction<ServerResponse> handlerFunction) {
|
||||
return add(RouterFunctions.route(predicate, handlerFunction));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouterFunctions.Builder resources(String pattern, Resource location) {
|
||||
return add(RouterFunctions.resources(pattern, location));
|
||||
|
||||
@@ -196,6 +196,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
public interface Builder {
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code GET} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code GET} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder GET(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
|
||||
* that match the given pattern.
|
||||
@@ -206,6 +214,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code GET} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder GET(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -220,12 +240,20 @@ public abstract class RouterFunctions {
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code GET} requests that
|
||||
* match {@code pattern}
|
||||
* match {@code pattern} and the predicate
|
||||
* @return this builder
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder GET(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code HEAD} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code HEAD} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder HEAD(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
|
||||
* that match the given pattern.
|
||||
@@ -236,6 +264,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code HEAD} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder HEAD(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -247,6 +287,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code POST} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code POST} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder POST(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
|
||||
* that match the given pattern.
|
||||
@@ -257,6 +305,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code POST} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder POST(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -276,6 +336,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder POST(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code PUT} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code PUT} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder PUT(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
|
||||
* that match the given pattern.
|
||||
@@ -286,6 +354,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code PUT} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder PUT(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -305,6 +385,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code PATCH} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code PATCH} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder PATCH(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
|
||||
* that match the given pattern.
|
||||
@@ -315,6 +403,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code PATCH} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder PATCH(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -334,6 +434,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code DELETE} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code DELETE} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder DELETE(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
|
||||
* that match the given pattern.
|
||||
@@ -344,6 +452,18 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code DELETE} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder DELETE(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
|
||||
* that match the given pattern and predicate.
|
||||
@@ -355,6 +475,14 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles HTTP {@code OPTIONS} requests.
|
||||
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
*/
|
||||
Builder OPTIONS(HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
|
||||
* that match the given pattern.
|
||||
@@ -366,15 +494,16 @@ public abstract class RouterFunctions {
|
||||
Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all requests that match the
|
||||
* given predicate.
|
||||
*
|
||||
* @param predicate the request predicate to match
|
||||
* @param handlerFunction the handler function to handle all requests that match the predicate
|
||||
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @param handlerFunction the handler function to handle all {@code OPTIONS} requests that
|
||||
* match {@code predicate}
|
||||
* @return this builder
|
||||
* @since 5.3
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder route(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
Builder OPTIONS(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
|
||||
@@ -387,6 +516,16 @@ public abstract class RouterFunctions {
|
||||
*/
|
||||
Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all requests that match the
|
||||
* given predicate.
|
||||
* @param predicate the request predicate to match
|
||||
* @param handlerFunction the handler function to handle all requests that match the predicate
|
||||
* @return this builder
|
||||
* @see RequestPredicates
|
||||
*/
|
||||
Builder route(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
|
||||
|
||||
/**
|
||||
* Adds the given route to this builder. Can be used to merge externally defined router
|
||||
* functions into this builder, or can be combined with
|
||||
|
||||
@@ -48,6 +48,7 @@ import java.util.function.Supplier
|
||||
* }
|
||||
* ```
|
||||
* @author Sebastien Deleuze
|
||||
* @author Arjen Poutsma
|
||||
* @since 5.2
|
||||
*/
|
||||
fun router(routes: (RouterFunctionDsl.() -> Unit)) = RouterFunctionDsl(routes).build()
|
||||
@@ -134,7 +135,6 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
builder.nest(this, Supplier(RouterFunctionDsl(r)::build))
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Route to the given router function if the given request predicate (String
|
||||
* processed as a path predicate) applies. This method can be used to create
|
||||
@@ -145,6 +145,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun String.nest(r: (RouterFunctionDsl.() -> Unit)) = path(this).nest(r)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `GET` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun GET(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.GET(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `GET` requests
|
||||
* that match the given pattern.
|
||||
@@ -156,7 +164,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `GET` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun GET(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.GET(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `GET` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -172,6 +190,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun GET(pattern: String): RequestPredicate = RequestPredicates.GET(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `HEAD` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun HEAD(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.HEAD(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
|
||||
* that match the given pattern.
|
||||
@@ -183,7 +209,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun HEAD(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.HEAD(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `HEAD` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -199,6 +235,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun HEAD(pattern: String): RequestPredicate = RequestPredicates.HEAD(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `POST` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun POST(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.POST(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `POST` requests
|
||||
* that match the given pattern.
|
||||
@@ -210,7 +254,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `POST` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun POST(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.POST(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `POST` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -226,6 +280,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun POST(pattern: String): RequestPredicate = RequestPredicates.POST(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PUT` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun PUT(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.PUT(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PUT` requests
|
||||
* that match the given pattern.
|
||||
@@ -237,7 +299,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PUT` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun PUT(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.PUT(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PUT` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -253,6 +325,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun PUT(pattern: String): RequestPredicate = RequestPredicates.PUT(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PATCH` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun PATCH(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.PATCH(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
|
||||
* that match the given pattern.
|
||||
@@ -264,7 +344,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun PATCH(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.PATCH(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `PATCH` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -282,6 +372,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun PATCH(pattern: String): RequestPredicate = RequestPredicates.PATCH(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `DELETE` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun DELETE(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.DELETE(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
|
||||
* that match the given pattern.
|
||||
@@ -293,7 +391,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun DELETE(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.DELETE(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `DELETE` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -311,6 +419,14 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
*/
|
||||
fun DELETE(pattern: String): RequestPredicate = RequestPredicates.DELETE(pattern)
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests.
|
||||
* @since 5.3
|
||||
*/
|
||||
fun OPTIONS(f: (ServerRequest) -> ServerResponse) {
|
||||
builder.OPTIONS(HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
|
||||
* that match the given pattern.
|
||||
@@ -322,7 +438,17 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
|
||||
* that match the given pattern.
|
||||
* that match the given predicate.
|
||||
* @param predicate predicate to match
|
||||
* @since 5.3
|
||||
*/
|
||||
fun OPTIONS(predicate: RequestPredicate, f: (ServerRequest) -> ServerResponse) {
|
||||
builder.OPTIONS(predicate, HandlerFunction(f))
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a route to the given handler function that handles all HTTP `OPTIONS` requests
|
||||
* that match the given pattern and predicate.
|
||||
* @param pattern the pattern to match to
|
||||
* @param predicate additional predicate to match
|
||||
* @since 5.2
|
||||
@@ -654,4 +780,4 @@ class RouterFunctionDsl internal constructor (private val init: (RouterFunctionD
|
||||
* Equivalent to [RouterFunction.and].
|
||||
*/
|
||||
operator fun <T: ServerResponse> RouterFunction<T>.plus(other: RouterFunction<T>) =
|
||||
this.and(other)
|
||||
this.and(other)
|
||||
|
||||
Reference in New Issue
Block a user