Class ResourceTransformerSupport
java.lang.Object
org.springframework.web.reactive.resource.ResourceTransformerSupport
- All Implemented Interfaces:
- ResourceTransformer
- Direct Known Subclasses:
- CssLinkResourceTransformer
A base class for a 
ResourceTransformer with an optional helper method
 for resolving public links within a transformed resource.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturn the configuredResourceUrlProvider.protected reactor.core.publisher.Mono<String>resolveUrlPath(String resourcePath, ServerWebExchange exchange, Resource resource, ResourceTransformerChain transformerChain) A transformer can use this method when a resource being transformed contains links to other resources.voidsetResourceUrlProvider(ResourceUrlProvider resourceUrlProvider) Configure aResourceUrlProviderto use when resolving the public URL of links in a transformed resource (for example, import links in a CSS file).protected StringtoAbsolutePath(String path, ServerWebExchange exchange) Transform the given relative request path to an absolute path, taking the path of the given request as a point of reference.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.reactive.resource.ResourceTransformertransform
- 
Constructor Details- 
ResourceTransformerSupportpublic ResourceTransformerSupport()
 
- 
- 
Method Details- 
setResourceUrlProviderConfigure aResourceUrlProviderto use when resolving the public URL of links in a transformed resource (for example, import links in a CSS file). This is required only for links expressed as full paths and not for relative links.- Parameters:
- resourceUrlProvider- the URL provider to use
 
- 
getResourceUrlProviderReturn the configuredResourceUrlProvider.
- 
resolveUrlPathprotected reactor.core.publisher.Mono<String> resolveUrlPath(String resourcePath, ServerWebExchange exchange, Resource resource, ResourceTransformerChain transformerChain) A transformer can use this method when a resource being transformed contains links to other resources. Such links need to be replaced with the public facing link as determined by the resource resolver chain (for example, the public URL may have a version inserted).- Parameters:
- resourcePath- the path to a resource that needs to be re-written
- exchange- the current exchange
- resource- the resource being transformed
- transformerChain- the transformer chain
- Returns:
- the resolved URL or an empty Mono
 
- 
toAbsolutePathTransform the given relative request path to an absolute path, taking the path of the given request as a point of reference. The resulting path is also cleaned from sequences like "path/..".- Parameters:
- path- the relative path to transform
- exchange- the current exchange
- Returns:
- the absolute request path for the given resource path
 
 
-