StaticContentConfig

A config for serving static content

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 behaviour 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 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 exclude(block: (Resource) -> Boolean)

Configures resources that should not be served. If this block returns true for Resource, Application will respond with HttpStatusCode.Forbidden. Can be invoked multiple times. For files, Resource is a requested File. For resources, Resource is a URL to a requested resource.

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 modify(block: suspend (Resource, <Error class: unknown class>) -> 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.