StaticContentConfig

A config for serving static content

Report a problem

Functions

Link copied to clipboard

Configures CacheControl for requested static content. For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

Link copied to clipboard
fun contentType(block: (Resource) -> ContentType?)

Configures ContentType for requested static content. If the block returns null, default behavior of guessing ContentType from the header will be used. For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

Link copied to clipboard
fun default(path: String?)

Configures default Resource to respond with when a requested file is not found.

Link copied to clipboard

Enables automatic response to a HEAD request for every file/resource that has a GET defined.

Link copied to clipboard
fun etag(block: ETagProvider)

Configures HttpHeaders.ETag for requested content. For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

Link copied to clipboard
fun exclude(block: (Resource) -> Boolean)

Configures resources that should not be served.

Link copied to clipboard
fun extensions(vararg extensions: String)

Configures file extension fallbacks. When set, if a file is not found, the search will repeat with the given extensions added to the file name. The first match will be served.

Link copied to clipboard
fun fallback(fallback: suspend (String, ApplicationCall) -> Unit)

Configures custom fallback behavior when a requested static resource is not found.

Link copied to clipboard
fun filter(block: (call: ApplicationCall) -> Boolean)

Configures calls that should be skipped.

Link copied to clipboard
fun lastModified(block: (Resource) -> GMTDate?)

Configures HttpHeaders.LastModified for requested static content. For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

Link copied to clipboard
fun modify(block: suspend (Resource, ApplicationCall) -> Unit)

Configures modification of a call for requested content. Useful to add headers to the response, such as HttpHeaders.ETag For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

Link copied to clipboard

Enables pre-compressed files or resources.