diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java index 5fa6a64774..92943358d3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java @@ -143,10 +143,10 @@ public abstract class RouterFunctions { * The returned function can be {@linkplain Function#andThen(Function) composed} on, for * instance to return a default resource when the lookup function does not match: *
-	 * Mono<Resource> defaultResource = Mono.just(new ClassPathResource("index.html"));
-	 * Function<ServerRequest, Mono<Resource>> lookupFunction =
+	 * Optional<Resource> defaultResource = Optional.of(new ClassPathResource("index.html"));
+	 * Function<ServerRequest, Optional<Resource>> lookupFunction =
 	 *   RouterFunctions.resourceLookupFunction("/resources/**", new FileSystemResource("public-resources/"))
-	 *     .andThen(resourceMono -> resourceMono.switchIfEmpty(defaultResource));
+	 *     .andThen(resource -> resource.or(() -> defaultResource));
 	 * RouterFunction<ServerResponse> resources = RouterFunctions.resources(lookupFunction);
      * 
* @param pattern the pattern to match @@ -168,11 +168,6 @@ public abstract class RouterFunctions { return new ResourcesRouterFunction(lookupFunction); } - @SuppressWarnings("unchecked") - static HandlerFunction cast(HandlerFunction handlerFunction) { - return (HandlerFunction) handlerFunction; - } - /** * Represents a discoverable builder for router functions. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java index 1a591c37b1..89b476ec08 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/ServerResponse.java @@ -76,7 +76,7 @@ public interface ServerResponse { * @param request the current request * @param response the response to write to * @param context the context to use when writing - * @return {@code Mono} to indicate when writing is complete + * @return a ModelAndView to render, or {@code null} if handled directly */ @Nullable ModelAndView writeTo(HttpServletRequest request, HttpServletResponse response, Context context)