org.springframework.web.reactive.resource

## Class ResourceUrlProvider

- java.lang.Object
- - org.springframework.web.reactive.resource.ResourceUrlProvider

All Implemented Interfaces:
  EventListener, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>

    public class ResourceUrlProvider
    extends Object
    implements org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>

A central component to use to obtain the public URL path that clients should use to access a static resource.

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.

Since:
  5.0
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`ResourceUrlProvider()`

### Method Summary

All Methods Instance Methods Concrete Methods
`reactor.core.publisher.Mono<String>` `getForUriString(String uriString, org.springframework.web.server.ServerWebExchange exchange)` Get the public resource URL for the given URI string.
`Map<org.springframework.web.util.pattern.PathPattern,ResourceWebHandler>` `getHandlerMap()` Return a read-only view of the resource handler mappings either manually configured or auto-detected from Spring configuration.
`void` `onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)`
`void` `registerHandlers(Map<String,ResourceWebHandler> handlerMap)` Manually configure resource handler mappings.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ResourceUrlProvider

    public ResourceUrlProvider()

### Method Detail

#### getHandlerMap

    public Map<org.springframework.web.util.pattern.PathPattern,ResourceWebHandler> getHandlerMap()

Return a read-only view of the resource handler mappings either manually configured or auto-detected from Spring configuration.

#### registerHandlers

    public void registerHandlers(Map<String,ResourceWebHandler> handlerMap)

Manually configure resource handler mappings.

Note: by default resource mappings are auto-detected from the Spring `ApplicationContext`. If this property is used, auto-detection is turned off.

#### onApplicationEvent

    public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)

Specified by:
  `onApplicationEvent` in interface `org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>`

#### getForUriString

    public final reactor.core.publisher.Mono<String> getForUriString(String uriString,
                                                                     org.springframework.web.server.ServerWebExchange exchange)

Get the public resource URL for the given URI string.

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.

Parameters:
  `uriString` - the URI string to transform
  `exchange` - the current exchange
Returns:
  the resolved public resource URL path, or empty if unresolved