Class ResourceUrlProvider

  • java.lang.Object
    • org.springframework.web.reactive.resource.ResourceUrlProvider
  • All Implemented Interfaces:
    java.util.EventListener, ApplicationListener<ContextRefreshedEvent>

    public class ResourceUrlProvider
    extends java.lang.Object
    implements ApplicationListener<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 ResourceHttpRequestHandlers to make its decisions.

    Rossen Stoyanchev
    • Constructor Detail

      • ResourceUrlProvider

        public ResourceUrlProvider()
    • Method Detail

      • getHandlerMap

        public java.util.Map<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(java.util.Map<java.lang.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.

      • getForUriString

        public final reactor.core.publisher.Mono<java.lang.String> getForUriString(java.lang.String uriString,
                                                                                   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.

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