@@ -30,23 +30,29 @@ public SwaggerResourceResolver(SwaggerUiConfigProperties swaggerUiConfigProperti
30
30
31
31
@ Override
32
32
public Mono <Resource > resolveResource (ServerWebExchange exchange , String requestPath , List <? extends Resource > locations , ResourceResolverChain chain ) {
33
- Mono <Resource > resolved = chain .resolveResource (exchange , requestPath , locations );
34
- if (!Mono .empty ().equals (resolved )) {
35
- String webJarResourcePath = findWebJarResourcePath (requestPath );
36
- if (webJarResourcePath != null )
37
- return chain .resolveResource (exchange , webJarResourcePath , locations );
38
- }
39
- return resolved ;
33
+ return chain .resolveResource (exchange , requestPath , locations )
34
+ .switchIfEmpty (Mono .defer (() -> {
35
+ String webJarsResourcePath = findWebJarResourcePath (requestPath );
36
+ if (webJarsResourcePath != null ) {
37
+ return chain .resolveResource (exchange , webJarsResourcePath , locations );
38
+ }
39
+ else {
40
+ return Mono .empty ();
41
+ }
42
+ }));
40
43
}
41
44
42
45
@ Override
43
- public Mono <String > resolveUrlPath (String resourcePath , List <? extends Resource > locations , ResourceResolverChain chain ) {
44
- Mono <String > path = chain .resolveUrlPath (resourcePath , locations );
45
- if (!Mono .empty ().equals (path )) {
46
- String webJarResourcePath = findWebJarResourcePath (resourcePath );
47
- if (webJarResourcePath != null )
48
- return chain .resolveUrlPath (webJarResourcePath , locations );
49
- }
50
- return path ;
46
+ public Mono <String > resolveUrlPath (String resourceUrlPath , List <? extends Resource > locations , ResourceResolverChain chain ) {
47
+ return chain .resolveUrlPath (resourceUrlPath , locations )
48
+ .switchIfEmpty (Mono .defer (() -> {
49
+ String webJarResourcePath = findWebJarResourcePath (resourceUrlPath );
50
+ if (webJarResourcePath != null ) {
51
+ return chain .resolveUrlPath (webJarResourcePath , locations );
52
+ }
53
+ else {
54
+ return Mono .empty ();
55
+ }
56
+ }));
51
57
}
52
58
}
0 commit comments