Browse Source

Update generics on WebFlux RouterFunctions.Builder

Consistently allow subtypes of ServerResponse to be returned for any
provided HandlerFunction and HandlerFilterFunction. Both allow use of
subtypes such as EntityServerResponse and RenderingResponse, and
in the end we support any ServerResponse.

Closes gh-35791
pull/34993/merge
rstoyanchev 1 month ago
parent
commit
7555d0e489
  1. 113
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctionBuilder.java
  2. 72
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java

113
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctionBuilder.java

@ -51,38 +51,38 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -51,38 +51,38 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
private final List<HandlerFilterFunction<ServerResponse, ServerResponse>> errorHandlers = new ArrayList<>();
@SuppressWarnings("unchecked")
@Override
public RouterFunctions.Builder add(RouterFunction<ServerResponse> routerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder add(RouterFunction<T> routerFunction) {
Assert.notNull(routerFunction, "RouterFunction must not be null");
this.routerFunctions.add(routerFunction);
this.routerFunctions.add((RouterFunction<ServerResponse>) routerFunction);
return this;
}
private RouterFunctions.Builder add(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
this.routerFunctions.add(RouterFunctions.route(predicate, handlerFunction));
return this;
private <T extends ServerResponse> RouterFunctions.Builder add(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RouterFunctions.route(predicate, handlerFunction));
}
// GET
@Override
public RouterFunctions.Builder GET(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder GET(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.GET), handlerFunction);
}
@Override
public RouterFunctions.Builder GET(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder GET(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.GET).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder GET(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.GET(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder GET(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder GET(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.GET(pattern).and(predicate), handlerFunction);
}
@ -90,23 +90,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -90,23 +90,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// HEAD
@Override
public RouterFunctions.Builder HEAD(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder HEAD(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.HEAD), handlerFunction);
}
@Override
public RouterFunctions.Builder HEAD(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder HEAD(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.HEAD).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder HEAD(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.HEAD(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder HEAD(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder HEAD(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.HEAD(pattern).and(predicate), handlerFunction);
}
@ -114,23 +114,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -114,23 +114,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// POST
@Override
public RouterFunctions.Builder POST(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder POST(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.POST), handlerFunction);
}
@Override
public RouterFunctions.Builder POST(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder POST(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.POST).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder POST(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.POST(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder POST(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder POST(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.POST(pattern).and(predicate), handlerFunction);
}
@ -138,23 +138,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -138,23 +138,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// PUT
@Override
public RouterFunctions.Builder PUT(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PUT(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.PUT), handlerFunction);
}
@Override
public RouterFunctions.Builder PUT(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PUT(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.PUT).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PUT(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.PUT(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder PUT(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PUT(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.PUT(pattern).and(predicate), handlerFunction);
}
@ -162,23 +162,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -162,23 +162,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// PATCH
@Override
public RouterFunctions.Builder PATCH(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PATCH(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.PATCH), handlerFunction);
}
@Override
public RouterFunctions.Builder PATCH(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PATCH(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.PATCH).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PATCH(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.PATCH(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder PATCH(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder PATCH(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.PATCH(pattern).and(predicate), handlerFunction);
}
@ -186,23 +186,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -186,23 +186,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// DELETE
@Override
public RouterFunctions.Builder DELETE(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder DELETE(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.DELETE), handlerFunction);
}
@Override
public RouterFunctions.Builder DELETE(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder DELETE(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.DELETE).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder DELETE(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.DELETE(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder DELETE(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder DELETE(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.DELETE(pattern).and(predicate), handlerFunction);
}
@ -210,23 +210,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -210,23 +210,23 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// OPTIONS
@Override
public RouterFunctions.Builder OPTIONS(HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder OPTIONS(HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.OPTIONS), handlerFunction);
}
@Override
public RouterFunctions.Builder OPTIONS(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder OPTIONS(RequestPredicate predicate, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.method(HttpMethod.OPTIONS).and(predicate), handlerFunction);
}
@Override
public RouterFunctions.Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder OPTIONS(String pattern, HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.OPTIONS(pattern), handlerFunction);
}
@Override
public RouterFunctions.Builder OPTIONS(String pattern, RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder OPTIONS(String pattern, RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RequestPredicates.OPTIONS(pattern).and(predicate), handlerFunction);
}
@ -234,8 +234,8 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -234,8 +234,8 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
// other
@Override
public RouterFunctions.Builder route(RequestPredicate predicate,
HandlerFunction<ServerResponse> handlerFunction) {
public <T extends ServerResponse> RouterFunctions.Builder route(RequestPredicate predicate,
HandlerFunction<T> handlerFunction) {
return add(RouterFunctions.route(predicate, handlerFunction));
}
@ -287,13 +287,14 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -287,13 +287,14 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
return this;
}
@SuppressWarnings("unchecked")
@Override
public RouterFunctions.Builder nest(RequestPredicate predicate,
Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier) {
public <T extends ServerResponse> RouterFunctions.Builder nest(RequestPredicate predicate,
Supplier<RouterFunction<T>> routerFunctionSupplier) {
Assert.notNull(routerFunctionSupplier, "RouterFunction Supplier must not be null");
RouterFunction<ServerResponse> nestedRoute = routerFunctionSupplier.get();
RouterFunction<ServerResponse> nestedRoute = (RouterFunction<ServerResponse>) routerFunctionSupplier.get();
this.routerFunctions.add(RouterFunctions.nest(predicate, nestedRoute));
return this;
}
@ -306,17 +307,20 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -306,17 +307,20 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
}
@Override
public RouterFunctions.Builder path(String pattern,
Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier) {
public <T extends ServerResponse> RouterFunctions.Builder path(String pattern,
Supplier<RouterFunction<T>> routerFunctionSupplier) {
return nest(RequestPredicates.path(pattern), routerFunctionSupplier);
}
@SuppressWarnings("unchecked")
@Override
public RouterFunctions.Builder filter(HandlerFilterFunction<ServerResponse, ServerResponse> filterFunction) {
public <T extends ServerResponse, R extends ServerResponse> RouterFunctions.Builder filter(
HandlerFilterFunction<T, R> filterFunction) {
Assert.notNull(filterFunction, "HandlerFilterFunction must not be null");
this.filterFunctions.add(filterFunction);
this.filterFunctions.add((HandlerFilterFunction<ServerResponse, ServerResponse>) filterFunction);
return this;
}
@ -326,18 +330,19 @@ class RouterFunctionBuilder implements RouterFunctions.Builder { @@ -326,18 +330,19 @@ class RouterFunctionBuilder implements RouterFunctions.Builder {
return filter((request, next) -> next.handle(requestProcessor.apply(request)));
}
@SuppressWarnings("unchecked")
@Override
public RouterFunctions.Builder after(
BiFunction<ServerRequest, ServerResponse, ServerResponse> responseProcessor) {
public <T extends ServerResponse, R extends ServerResponse> RouterFunctions.Builder after(
BiFunction<ServerRequest, T, R> responseProcessor) {
Assert.notNull(responseProcessor, "ResponseProcessor must not be null");
return filter((request, next) -> next.handle(request)
.map(serverResponse -> responseProcessor.apply(request, serverResponse)));
.map(serverResponse -> responseProcessor.apply(request, (T) serverResponse)));
}
@Override
public RouterFunctions.Builder onError(Predicate<? super Throwable> predicate,
BiFunction<? super Throwable, ServerRequest, Mono<ServerResponse>> responseProvider) {
public <T extends ServerResponse> RouterFunctions.Builder onError(Predicate<? super Throwable> predicate,
BiFunction<? super Throwable, ServerRequest, Mono<T>> responseProvider) {
Assert.notNull(predicate, "Predicate must not be null");
Assert.notNull(responseProvider, "ResponseProvider must not be null");

72
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RouterFunctions.java

@ -364,7 +364,7 @@ public abstract class RouterFunctions { @@ -364,7 +364,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder GET(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder GET(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
@ -375,7 +375,7 @@ public abstract class RouterFunctions { @@ -375,7 +375,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder GET(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder GET(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
@ -387,7 +387,7 @@ public abstract class RouterFunctions { @@ -387,7 +387,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder GET(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder GET(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code GET} requests
@ -408,7 +408,7 @@ public abstract class RouterFunctions { @@ -408,7 +408,7 @@ public abstract class RouterFunctions {
* @see org.springframework.web.util.pattern.PathPattern
* @see RequestPredicates
*/
Builder GET(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder GET(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code HEAD} requests.
@ -416,7 +416,7 @@ public abstract class RouterFunctions { @@ -416,7 +416,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder HEAD(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder HEAD(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
@ -427,7 +427,7 @@ public abstract class RouterFunctions { @@ -427,7 +427,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder HEAD(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
@ -439,7 +439,7 @@ public abstract class RouterFunctions { @@ -439,7 +439,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder HEAD(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder HEAD(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code HEAD} requests
@ -451,7 +451,7 @@ public abstract class RouterFunctions { @@ -451,7 +451,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder HEAD(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code POST} requests.
@ -459,7 +459,7 @@ public abstract class RouterFunctions { @@ -459,7 +459,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder POST(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder POST(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
@ -470,7 +470,7 @@ public abstract class RouterFunctions { @@ -470,7 +470,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder POST(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
@ -482,7 +482,7 @@ public abstract class RouterFunctions { @@ -482,7 +482,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder POST(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder POST(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code POST} requests
@ -502,7 +502,7 @@ public abstract class RouterFunctions { @@ -502,7 +502,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder POST(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder POST(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code PUT} requests.
@ -510,7 +510,7 @@ public abstract class RouterFunctions { @@ -510,7 +510,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder PUT(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PUT(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
@ -521,7 +521,7 @@ public abstract class RouterFunctions { @@ -521,7 +521,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PUT(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
@ -533,7 +533,7 @@ public abstract class RouterFunctions { @@ -533,7 +533,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder PUT(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PUT(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PUT} requests
@ -553,7 +553,7 @@ public abstract class RouterFunctions { @@ -553,7 +553,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PUT(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code PATCH} requests.
@ -561,7 +561,7 @@ public abstract class RouterFunctions { @@ -561,7 +561,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder PATCH(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PATCH(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
@ -572,7 +572,7 @@ public abstract class RouterFunctions { @@ -572,7 +572,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PATCH(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
@ -584,7 +584,7 @@ public abstract class RouterFunctions { @@ -584,7 +584,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder PATCH(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PATCH(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code PATCH} requests
@ -604,7 +604,7 @@ public abstract class RouterFunctions { @@ -604,7 +604,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder PATCH(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code DELETE} requests.
@ -612,7 +612,7 @@ public abstract class RouterFunctions { @@ -612,7 +612,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder DELETE(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder DELETE(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
@ -623,7 +623,7 @@ public abstract class RouterFunctions { @@ -623,7 +623,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder DELETE(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
@ -635,7 +635,7 @@ public abstract class RouterFunctions { @@ -635,7 +635,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder DELETE(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder DELETE(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code DELETE} requests
@ -647,7 +647,7 @@ public abstract class RouterFunctions { @@ -647,7 +647,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder DELETE(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles HTTP {@code OPTIONS} requests.
@ -655,7 +655,7 @@ public abstract class RouterFunctions { @@ -655,7 +655,7 @@ public abstract class RouterFunctions {
* @return this builder
* @since 5.3
*/
Builder OPTIONS(HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder OPTIONS(HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
@ -666,7 +666,7 @@ public abstract class RouterFunctions { @@ -666,7 +666,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder OPTIONS(String pattern, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
@ -678,7 +678,7 @@ public abstract class RouterFunctions { @@ -678,7 +678,7 @@ public abstract class RouterFunctions {
* @since 5.3
* @see RequestPredicates
*/
Builder OPTIONS(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder OPTIONS(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all HTTP {@code OPTIONS} requests
@ -690,7 +690,7 @@ public abstract class RouterFunctions { @@ -690,7 +690,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder OPTIONS(String pattern, RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds a route to the given handler function that handles all requests that match the
@ -701,7 +701,7 @@ public abstract class RouterFunctions { @@ -701,7 +701,7 @@ public abstract class RouterFunctions {
* @since 5.2
* @see RequestPredicates
*/
Builder route(RequestPredicate predicate, HandlerFunction<ServerResponse> handlerFunction);
<T extends ServerResponse> Builder route(RequestPredicate predicate, HandlerFunction<T> handlerFunction);
/**
* Adds the given route to this builder. Can be used to merge externally defined router
@ -722,7 +722,7 @@ public abstract class RouterFunctions { @@ -722,7 +722,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see RequestPredicates
*/
Builder add(RouterFunction<ServerResponse> routerFunction);
<T extends ServerResponse> Builder add(RouterFunction<T> routerFunction);
/**
* Route requests that match the given predicate to the given resource.
@ -826,7 +826,7 @@ public abstract class RouterFunctions { @@ -826,7 +826,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see RequestPredicates
*/
Builder nest(RequestPredicate predicate, Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier);
<T extends ServerResponse> Builder nest(RequestPredicate predicate, Supplier<RouterFunction<T>> routerFunctionSupplier);
/**
* Route to a built router function if the given request predicate applies.
@ -872,7 +872,7 @@ public abstract class RouterFunctions { @@ -872,7 +872,7 @@ public abstract class RouterFunctions {
* @return this builder
* @see org.springframework.web.util.pattern.PathPattern
*/
Builder path(String pattern, Supplier<RouterFunction<ServerResponse>> routerFunctionSupplier);
<T extends ServerResponse> Builder path(String pattern, Supplier<RouterFunction<T>> routerFunctionSupplier);
/**
* Route to a built router function if the given path prefix pattern applies.
@ -921,7 +921,7 @@ public abstract class RouterFunctions { @@ -921,7 +921,7 @@ public abstract class RouterFunctions {
* @param filterFunction the function to filter all routes built by this builder
* @return this builder
*/
Builder filter(HandlerFilterFunction<ServerResponse, ServerResponse> filterFunction);
<T extends ServerResponse, R extends ServerResponse> Builder filter(HandlerFilterFunction<T, R> filterFunction);
/**
* Filter the request object for all routes created by this builder with the given request
@ -963,7 +963,7 @@ public abstract class RouterFunctions { @@ -963,7 +963,7 @@ public abstract class RouterFunctions {
* @param responseProcessor a function that transforms the response
* @return this builder
*/
Builder after(BiFunction<ServerRequest, ServerResponse, ServerResponse> responseProcessor);
<T extends ServerResponse, R extends ServerResponse> Builder after(BiFunction<ServerRequest, T, R> responseProcessor);
/**
* Filters all exceptions that match the predicate by applying the given response provider
@ -982,8 +982,8 @@ public abstract class RouterFunctions { @@ -982,8 +982,8 @@ public abstract class RouterFunctions {
* @param responseProvider a function that creates a response
* @return this builder
*/
Builder onError(Predicate<? super Throwable> predicate,
BiFunction<? super Throwable, ServerRequest, Mono<ServerResponse>> responseProvider);
<T extends ServerResponse> Builder onError(Predicate<? super Throwable> predicate,
BiFunction<? super Throwable, ServerRequest, Mono<T>> responseProvider);
/**
* Filters all exceptions of the given type by applying the given response provider

Loading…
Cancel
Save