@@ -67,7 +67,8 @@ public abstract class RouterFunctions {
67
67
public static final String URI_TEMPLATE_VARIABLES_ATTRIBUTE =
68
68
RouterFunctions .class .getName () + ".uriTemplateVariables" ;
69
69
70
- private static final HandlerFunction <ServerResponse > NOT_FOUND_HANDLER = request -> ServerResponse .notFound ().build ();
70
+ private static final HandlerFunction <ServerResponse > NOT_FOUND_HANDLER =
71
+ request -> ServerResponse .notFound ().build ();
71
72
72
73
73
74
/**
@@ -103,9 +104,8 @@ public static <T extends ServerResponse> RouterFunction<T> route(
103
104
* RouterFunction<ServerResponse> userRoutes =
104
105
* RouterFunctions.route(RequestPredicates.method(HttpMethod.GET), this::listUsers)
105
106
* .andRoute(RequestPredicates.method(HttpMethod.POST), this::createUser);
106
- *
107
107
* RouterFunction<ServerResponse> nestedRoute =
108
- * RouterFunctions.nest(RequestPredicates.path("/user"),userRoutes);
108
+ * RouterFunctions.nest(RequestPredicates.path("/user"), userRoutes);
109
109
* </pre>
110
110
* @param predicate the predicate to test
111
111
* @param routerFunction the nested router function to delegate to if the predicate applies
@@ -125,7 +125,7 @@ public static <T extends ServerResponse> RouterFunction<T> nest(
125
125
* For instance
126
126
* <pre class="code">
127
127
* Resource location = new FileSystemResource("public-resources/");
128
- * RoutingFunction <ServerResponse> resources = RouterFunctions.resources("/resources/**", location);
128
+ * RouterFunction <ServerResponse> resources = RouterFunctions.resources("/resources/**", location);
129
129
* </pre>
130
130
* @param pattern the pattern to match
131
131
* @param location the location directory relative to which resources should be resolved
@@ -225,12 +225,13 @@ public static WebHandler toWebHandler(RouterFunction<?> routerFunction, HandlerS
225
225
};
226
226
}
227
227
228
+
228
229
private static <T > Mono <T > wrapException (Supplier <Mono <T >> supplier ) {
229
230
try {
230
231
return supplier .get ();
231
232
}
232
- catch (Throwable t ) {
233
- return Mono .error (t );
233
+ catch (Throwable ex ) {
234
+ return Mono .error (ex );
234
235
}
235
236
}
236
237
@@ -303,6 +304,7 @@ public String toString() {
303
304
}
304
305
}
305
306
307
+
306
308
static final class SameComposedRouterFunction <T extends ServerResponse > extends AbstractRouterFunction <T > {
307
309
308
310
private final RouterFunction <T > first ;
@@ -350,9 +352,9 @@ public void accept(Visitor visitor) {
350
352
this .first .accept (visitor );
351
353
this .second .accept (visitor );
352
354
}
353
-
354
355
}
355
356
357
+
356
358
static final class FilteredRouterFunction <T extends ServerResponse , S extends ServerResponse >
357
359
implements RouterFunction <S > {
358
360
@@ -383,8 +385,8 @@ public String toString() {
383
385
}
384
386
}
385
387
386
- private static final class DefaultRouterFunction < T extends ServerResponse >
387
- extends AbstractRouterFunction <T > {
388
+
389
+ private static final class DefaultRouterFunction < T extends ServerResponse > extends AbstractRouterFunction <T > {
388
390
389
391
private final RequestPredicate predicate ;
390
392
@@ -414,11 +416,10 @@ public Mono<HandlerFunction<T>> route(ServerRequest request) {
414
416
public void accept (Visitor visitor ) {
415
417
visitor .route (this .predicate , this .handlerFunction );
416
418
}
417
-
418
419
}
419
420
420
- private static final class DefaultNestedRouterFunction < T extends ServerResponse >
421
- extends AbstractRouterFunction <T > {
421
+
422
+ private static final class DefaultNestedRouterFunction < T extends ServerResponse > extends AbstractRouterFunction <T > {
422
423
423
424
private final RequestPredicate predicate ;
424
425
@@ -446,15 +447,15 @@ public Mono<HandlerFunction<T>> route(ServerRequest serverRequest) {
446
447
mergeTemplateVariables (serverRequest , nestedRequest .pathVariables ());
447
448
});
448
449
}
449
- )
450
- .orElseGet (Mono ::empty );
450
+ ).orElseGet (Mono ::empty );
451
451
}
452
452
453
453
@ SuppressWarnings ("unchecked" )
454
454
private void mergeTemplateVariables (ServerRequest request , Map <String , String > variables ) {
455
455
if (!variables .isEmpty ()) {
456
456
Map <String , Object > attributes = request .attributes ();
457
- Map <String , String > oldVariables = (Map <String , String >)request .attribute (RouterFunctions .URI_TEMPLATE_VARIABLES_ATTRIBUTE )
457
+ Map <String , String > oldVariables =
458
+ (Map <String , String >) request .attribute (RouterFunctions .URI_TEMPLATE_VARIABLES_ATTRIBUTE )
458
459
.orElseGet (LinkedHashMap ::new );
459
460
Map <String , String > mergedVariables = new LinkedHashMap <>(oldVariables );
460
461
mergedVariables .putAll (variables );
@@ -469,9 +470,9 @@ public void accept(Visitor visitor) {
469
470
this .routerFunction .accept (visitor );
470
471
visitor .endNested (this .predicate );
471
472
}
472
-
473
473
}
474
474
475
+
475
476
private static class ResourcesRouterFunction extends AbstractRouterFunction <ServerResponse > {
476
477
477
478
private final Function <ServerRequest , Mono <Resource >> lookupFunction ;
@@ -492,6 +493,7 @@ public void accept(Visitor visitor) {
492
493
}
493
494
}
494
495
496
+
495
497
private static class HandlerStrategiesResponseContext implements ServerResponse .Context {
496
498
497
499
private final HandlerStrategies strategies ;
0 commit comments