@@ -160,6 +160,7 @@ public static RouterFunction<ServerResponse> resource(RequestPredicate predicate
160
160
*/
161
161
public static RouterFunction <ServerResponse > resource (RequestPredicate predicate , Resource resource ,
162
162
BiConsumer <Resource , HttpHeaders > headersConsumer ) {
163
+
163
164
return resources (new PredicateResourceLookupFunction (predicate , resource ), headersConsumer );
164
165
}
165
166
@@ -197,6 +198,7 @@ public static RouterFunction<ServerResponse> resources(String pattern, Resource
197
198
*/
198
199
public static RouterFunction <ServerResponse > resources (String pattern , Resource location ,
199
200
BiConsumer <Resource , HttpHeaders > headersConsumer ) {
201
+
200
202
return resources (resourceLookupFunction (pattern , location ), headersConsumer );
201
203
}
202
204
@@ -240,7 +242,9 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
240
242
* @return a router function that routes to resources
241
243
* @since 6.1
242
244
*/
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
+
244
248
return new ResourcesRouterFunction (lookupFunction , headersConsumer );
245
249
}
246
250
@@ -250,12 +254,12 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
250
254
* can be used to change the {@code PathPatternParser} properties from the defaults, for instance to change
251
255
* {@linkplain PathPatternParser#setCaseSensitive(boolean) case sensitivity}.
252
256
* @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
254
258
* @param <T> the type of response returned by the handler function
255
259
* @return the change router function
256
260
*/
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 ) {
259
263
260
264
Assert .notNull (routerFunction , "RouterFunction must not be null" );
261
265
Assert .notNull (parser , "Parser must not be null" );
@@ -1151,7 +1155,6 @@ public Optional<HandlerFunction<T>> route(ServerRequest request) {
1151
1155
public void accept (Visitor visitor ) {
1152
1156
visitor .route (this .predicate , this .handlerFunction );
1153
1157
}
1154
-
1155
1158
}
1156
1159
1157
1160
@@ -1173,13 +1176,10 @@ public Optional<HandlerFunction<T>> route(ServerRequest serverRequest) {
1173
1176
return this .predicate .nest (serverRequest )
1174
1177
.map (nestedRequest -> {
1175
1178
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 ));
1180
1181
}
1181
- Optional <HandlerFunction <T >> result =
1182
- this .routerFunction .route (nestedRequest );
1182
+ Optional <HandlerFunction <T >> result = this .routerFunction .route (nestedRequest );
1183
1183
if (result .isPresent () && nestedRequest != serverRequest ) {
1184
1184
serverRequest .attributes ().clear ();
1185
1185
serverRequest .attributes ().putAll (nestedRequest .attributes ());
@@ -1197,7 +1197,6 @@ public void accept(Visitor visitor) {
1197
1197
this .routerFunction .accept (visitor );
1198
1198
visitor .endNested (this .predicate );
1199
1199
}
1200
-
1201
1200
}
1202
1201
1203
1202
@@ -1207,11 +1206,11 @@ private static class ResourcesRouterFunction extends AbstractRouterFunction<Serv
1207
1206
1208
1207
private final BiConsumer <Resource , HttpHeaders > headersConsumer ;
1209
1208
1210
-
1211
1209
public ResourcesRouterFunction (Function <ServerRequest , Optional <Resource >> lookupFunction ,
1212
1210
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" );
1215
1214
this .lookupFunction = lookupFunction ;
1216
1215
this .headersConsumer = headersConsumer ;
1217
1216
}
@@ -1279,5 +1278,4 @@ public RouterFunction<T> withAttributes(Consumer<Map<String, Object>> attributes
1279
1278
}
1280
1279
}
1281
1280
1282
-
1283
1281
}
0 commit comments