Closes gh-23075
This commit is contained in:
Arjen Poutsma
2019-06-04 15:30:20 +02:00
parent e92ace7301
commit 145610129b
2 changed files with 4 additions and 9 deletions

View File

@@ -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:
* <pre class="code">
* Mono&lt;Resource&gt; defaultResource = Mono.just(new ClassPathResource("index.html"));
* Function&lt;ServerRequest, Mono&lt;Resource&gt;&gt; lookupFunction =
* Optional&lt;Resource&gt; defaultResource = Optional.of(new ClassPathResource("index.html"));
* Function&lt;ServerRequest, Optional&lt;Resource&gt;&gt; lookupFunction =
* RouterFunctions.resourceLookupFunction("/resources/**", new FileSystemResource("public-resources/"))
* .andThen(resourceMono -&gt; resourceMono.switchIfEmpty(defaultResource));
* .andThen(resource -&gt; resource.or(() -&gt; defaultResource));
* RouterFunction&lt;ServerResponse&gt; resources = RouterFunctions.resources(lookupFunction);
* </pre>
* @param pattern the pattern to match
@@ -168,11 +168,6 @@ public abstract class RouterFunctions {
return new ResourcesRouterFunction(lookupFunction);
}
@SuppressWarnings("unchecked")
static <T extends ServerResponse> HandlerFunction<T> cast(HandlerFunction<?> handlerFunction) {
return (HandlerFunction<T>) handlerFunction;
}
/**
* Represents a discoverable builder for router functions.

View File

@@ -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<Void>} 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)