Add route(RequestPredicate, HandlerFunction) to RouterFunctions builder

Closes gh-22701
This commit is contained in:
Arjen Poutsma
2019-05-07 16:47:05 +02:00
parent bb002af8af
commit 00a5106bfa
3 changed files with 31 additions and 3 deletions

View File

@@ -132,6 +132,12 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
return add(RequestPredicates.OPTIONS(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder route(RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
return add(RouterFunctions.route(predicate, handlerFunction));
}
@Override
public RouterFunctions.Builder OPTIONS(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {

View File

@@ -349,6 +349,17 @@ 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
* @return this builder
* @see RequestPredicates
*/
Builder route(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
* that match the given pattern and predicate.