@@ -160,6 +160,7 @@ public static RouterFunction<ServerResponse> resource(RequestPredicate predicate
160160 */
161161 public static RouterFunction <ServerResponse > resource (RequestPredicate predicate , Resource resource ,
162162 BiConsumer <Resource , HttpHeaders > headersConsumer ) {
163+
163164 return resources (new PredicateResourceLookupFunction (predicate , resource ), headersConsumer );
164165 }
165166
@@ -197,6 +198,7 @@ public static RouterFunction<ServerResponse> resources(String pattern, Resource
197198 */
198199 public static RouterFunction <ServerResponse > resources (String pattern , Resource location ,
199200 BiConsumer <Resource , HttpHeaders > headersConsumer ) {
201+
200202 return resources (resourceLookupFunction (pattern , location ), headersConsumer );
201203 }
202204
@@ -240,7 +242,9 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
240242 * @return a router function that routes to resources
241243 * @since 6.1
242244 */
243- public static RouterFunction <ServerResponse > resources (Function <ServerRequest , Optional <Resource >> lookupFunction , BiConsumer <Resource , HttpHeaders > headersConsumer ) {
245+ public static RouterFunction <ServerResponse > resources (Function <ServerRequest , Optional <Resource >> lookupFunction ,
246+ BiConsumer <Resource , HttpHeaders > headersConsumer ) {
247+
244248 return new ResourcesRouterFunction (lookupFunction , headersConsumer );
245249 }
246250
@@ -250,12 +254,12 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
250254 * can be used to change the {@code PathPatternParser} properties from the defaults, for instance to change
251255 * {@linkplain PathPatternParser#setCaseSensitive(boolean) case sensitivity}.
252256 * @param routerFunction the router function to change the parser in
253- * @param parser the parser to change to.
257+ * @param parser the parser to change to
254258 * @param <T> the type of response returned by the handler function
255259 * @return the change router function
256260 */
257- public static <T extends ServerResponse > RouterFunction <T > changeParser (RouterFunction < T > routerFunction ,
258- PathPatternParser parser ) {
261+ public static <T extends ServerResponse > RouterFunction <T > changeParser (
262+ RouterFunction < T > routerFunction , PathPatternParser parser ) {
259263
260264 Assert .notNull (routerFunction , "RouterFunction must not be null" );
261265 Assert .notNull (parser , "Parser must not be null" );
@@ -1151,7 +1155,6 @@ public Optional<HandlerFunction<T>> route(ServerRequest request) {
11511155 public void accept (Visitor visitor ) {
11521156 visitor .route (this .predicate , this .handlerFunction );
11531157 }
1154-
11551158 }
11561159
11571160
@@ -1173,13 +1176,10 @@ public Optional<HandlerFunction<T>> route(ServerRequest serverRequest) {
11731176 return this .predicate .nest (serverRequest )
11741177 .map (nestedRequest -> {
11751178 if (logger .isTraceEnabled ()) {
1176- logger .trace (
1177- String .format (
1178- "Nested predicate \" %s\" matches against \" %s\" " ,
1179- this .predicate , serverRequest ));
1179+ logger .trace (String .format ("Nested predicate \" %s\" matches against \" %s\" " ,
1180+ this .predicate , serverRequest ));
11801181 }
1181- Optional <HandlerFunction <T >> result =
1182- this .routerFunction .route (nestedRequest );
1182+ Optional <HandlerFunction <T >> result = this .routerFunction .route (nestedRequest );
11831183 if (result .isPresent () && nestedRequest != serverRequest ) {
11841184 serverRequest .attributes ().clear ();
11851185 serverRequest .attributes ().putAll (nestedRequest .attributes ());
@@ -1197,7 +1197,6 @@ public void accept(Visitor visitor) {
11971197 this .routerFunction .accept (visitor );
11981198 visitor .endNested (this .predicate );
11991199 }
1200-
12011200 }
12021201
12031202
@@ -1207,11 +1206,11 @@ private static class ResourcesRouterFunction extends AbstractRouterFunction<Serv
12071206
12081207 private final BiConsumer <Resource , HttpHeaders > headersConsumer ;
12091208
1210-
12111209 public ResourcesRouterFunction (Function <ServerRequest , Optional <Resource >> lookupFunction ,
12121210 BiConsumer <Resource , HttpHeaders > headersConsumer ) {
1213- Assert .notNull (lookupFunction , "Function must not be null" );
1214- Assert .notNull (headersConsumer , "HeadersConsumer must not be null" );
1211+
1212+ Assert .notNull (lookupFunction , "Lookup function must not be null" );
1213+ Assert .notNull (headersConsumer , "Headers consumer must not be null" );
12151214 this .lookupFunction = lookupFunction ;
12161215 this .headersConsumer = headersConsumer ;
12171216 }
@@ -1279,5 +1278,4 @@ public RouterFunction<T> withAttributes(Consumer<Map<String, Object>> attributes
12791278 }
12801279 }
12811280
1282-
12831281}
0 commit comments