Top Description Methods
org.springframework.web.reactive.resource

public Interface ResourceResolver

Known Direct Implementers
org.springframework.web.reactive.resource.AbstractResourceResolver
Imports
java.util.List, reactor.core.publisher.Mono, org.springframework.core.io.Resource, org.springframework.http.server.RequestPath, org.springframework.lang.Nullable, org.springframework.web.server.ServerWebExchange

A strategy for resolving a request to a server-side resource.

Provides mechanisms for resolving an incoming request to an actual Resource and for obtaining the public URL path that clients should use when requesting the resource.

Author
Rossen Stoyanchev
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public Mono<Resource>

Returns:

the resolved resource or an empty Mono if unresolved
resolveResource
(ServerWebExchange
the current exchange
exchange
,
String
the portion of the request path to use. This is expected to be the encoded path, i.e. RequestPath#value().
requestPath
,
List<? extends Resource>
the locations to search in when looking up resources
locations
,
ResourceResolverChain
the chain of remaining resolvers to delegate to
chain
)

Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.

public Mono<String>

Returns:

the resolved public URL path or an empty Mono if unresolved
resolveUrlPath
(String
the "internal" resource path to resolve a path for public use. This is expected to be the encoded path.
resourcePath
,
List<? extends Resource>
the locations to search in when looking up resources
locations
,
ResourceResolverChain
the chain of resolvers to delegate to
chain
)

Resolve the externally facing public URL path for clients to use to access the resource that is located at the given internal resource path.

Method Detail

resolveResourceback to summary
public Mono<Resource> resolveResource(ServerWebExchange exchange, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)

Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.

Parameters
exchange:ServerWebExchange

the current exchange

requestPath:String

the portion of the request path to use. This is expected to be the encoded path, i.e. RequestPath#value().

locations:List<? extends Resource>

the locations to search in when looking up resources

chain:ResourceResolverChain

the chain of remaining resolvers to delegate to

Returns:Mono<Resource>

the resolved resource or an empty Mono if unresolved

resolveUrlPathback to summary
public Mono<String> resolveUrlPath(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain)

Resolve the externally facing public URL path for clients to use to access the resource that is located at the given internal resource path.

This is useful when rendering URL links to clients.

Parameters
resourcePath:String

the "internal" resource path to resolve a path for public use. This is expected to be the encoded path.

locations:List<? extends Resource>

the locations to search in when looking up resources

chain:ResourceResolverChain

the chain of resolvers to delegate to

Returns:Mono<String>

the resolved public URL path or an empty Mono if unresolved