Skip to content

Commit

Permalink
A question about resource path processing. Fixes #2348
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Dec 2, 2023
1 parent a1de9ad commit b6f9c1d
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,29 @@ public SwaggerResourceResolver(SwaggerUiConfigProperties swaggerUiConfigProperti

@Override
public Mono<Resource> resolveResource(ServerWebExchange exchange, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) {
Mono<Resource> resolved = chain.resolveResource(exchange, requestPath, locations);
if (!Mono.empty().equals(resolved)) {
String webJarResourcePath = findWebJarResourcePath(requestPath);
if (webJarResourcePath != null)
return chain.resolveResource(exchange, webJarResourcePath, locations);
}
return resolved;
return chain.resolveResource(exchange, requestPath, locations)
.switchIfEmpty(Mono.defer(() -> {
String webJarsResourcePath = findWebJarResourcePath(requestPath);
if (webJarsResourcePath != null) {
return chain.resolveResource(exchange, webJarsResourcePath, locations);
}
else {
return Mono.empty();
}
}));
}

@Override
public Mono<String> resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain) {
Mono<String> path = chain.resolveUrlPath(resourcePath, locations);
if (!Mono.empty().equals(path)) {
String webJarResourcePath = findWebJarResourcePath(resourcePath);
if (webJarResourcePath != null)
return chain.resolveUrlPath(webJarResourcePath, locations);
}
return path;
public Mono<String> resolveUrlPath(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) {
return chain.resolveUrlPath(resourceUrlPath, locations)
.switchIfEmpty(Mono.defer(() -> {
String webJarResourcePath = findWebJarResourcePath(resourceUrlPath);
if (webJarResourcePath != null) {
return chain.resolveUrlPath(webJarResourcePath, locations);
}
else {
return Mono.empty();
}
}));
}
}

0 comments on commit b6f9c1d

Please sign in to comment.