spring-framework / org.springframework.web.reactive.config / ResourceHandlerRegistration

ResourceHandlerRegistration

open class ResourceHandlerRegistration

Assist with creating and configuring a static resources handler.

Author
Rossen Stoyanchev

Since
5.0

Constructors

<init>

ResourceHandlerRegistration(resourceLoader: ResourceLoader, vararg pathPatterns: String)

Create a ResourceHandlerRegistration instance.

Functions

addResourceLocations

open fun addResourceLocations(vararg resourceLocations: String): ResourceHandlerRegistration

Add one or more resource locations from which to serve static content. Each location must point to a valid directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked for a given resource in the order specified.

For example, {"/", "classpath:/META-INF/public-web-resources/"} allows resources to be served both from the web application root and from any JAR on the classpath that contains a /META-INF/public-web-resources/ directory, with resources in the web application root taking precedence.

resourceChain

open fun resourceChain(cacheResources: Boolean): ResourceChainRegistration
open fun resourceChain(cacheResources: Boolean, cache: Cache): ResourceChainRegistration

Configure a chain of resource resolvers and transformers to use. This can be useful, for example, to apply a version strategy to resource URLs.

If this method is not invoked, by default only a simple PathResourceResolver is used in order to match URL paths to resources under the configured locations.

setCacheControl

open fun setCacheControl(cacheControl: CacheControl): ResourceHandlerRegistration

Specify the CacheControl which should be used by the resource handler.