public class ResourceUrlProvider extends Object implements ApplicationListener<ContextRefreshedEvent>
This class is aware of Spring WebFlux handler mappings used to serve static
resources and uses the ResourceResolver
chains of the configured
ResourceHttpRequestHandler
s to make its decisions.
Constructor and Description |
---|
ResourceUrlProvider() |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<String> |
getForUriString(String uriString,
ServerWebExchange exchange)
Get the public resource URL for the given URI string.
|
Map<PathPattern,ResourceWebHandler> |
getHandlerMap()
Return a read-only view of the resource handler mappings either manually
configured or auto-detected from Spring configuration.
|
void |
onApplicationEvent(ContextRefreshedEvent event)
Handle an application event.
|
void |
registerHandlers(Map<String,ResourceWebHandler> handlerMap)
Manually configure resource handler mappings.
|
public Map<PathPattern,ResourceWebHandler> getHandlerMap()
public void registerHandlers(Map<String,ResourceWebHandler> handlerMap)
Note: by default resource mappings are auto-detected
from the Spring ApplicationContext
. If this property is used,
auto-detection is turned off.
public void onApplicationEvent(ContextRefreshedEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<ContextRefreshedEvent>
event
- the event to respond topublic final reactor.core.publisher.Mono<String> getForUriString(String uriString, ServerWebExchange exchange)
The URI string is expected to be a path and if it contains a query or fragment those will be preserved in the resulting public resource URL.
uriString
- the URI string to transformexchange
- the current exchange