Package io.ktor.server.http.content

Types

Link copied to clipboard
enum CompressedFileType : Enum<CompressedFileType>

Supported pre compressed file types and associated extensions

Link copied to clipboard
class HttpStatusCodeContent(value: <ERROR CLASS>)

Represents a simple status code response with no content

Link copied to clipboard
class JarFileContent(jarFile: File, resourcePath: String, contentType: ContentType) : OutgoingContent.ReadChannelContent

Represents an OutgoingContent for a resource inside a Jar file

Link copied to clipboard
class LocalFileContent(file: File, contentType: ContentType) : OutgoingContent.ReadChannelContent

OutgoingContent representing a local file with a specified contentType, expires date and caching

Link copied to clipboard
class SPAConfig(defaultPage: String, applicationRoute: String, filesPath: String, useResources: Boolean, ignoredFiles: MutableList<(String) -> Boolean>)

Configuration for the Route.singlePageApplication plugin.

Functions

Link copied to clipboard
fun SPAConfig.angular(filesPath: String)

Creates an application configuration for the Angular project. Resources will be shared from the filesPath directory. The root file is index.html

Link copied to clipboard
fun SPAConfig.backbone(filesPath: String)

Creates an application configuration for the Backbone project. Resources will be shared from the filesPath directory. The root file is index.html

Link copied to clipboard
fun CachingOptions(cacheControl: CacheControl? = null, expires: ZonedDateTime): CachingOptions

Creates CachingOptions instance with ZonedDateTime expiration time

Link copied to clipboard
fun Route.default(localPath: File)
fun Route.default(localPath: String)

Specifies localPath as a default file to serve when folder is requested

Link copied to clipboard
fun Route.defaultResource(resource: String, resourcePackage: String? = null)

Specifies resource as a default resources to serve when folder is requested

Link copied to clipboard
fun SPAConfig.ember(filesPath: String)

Creates an application configuration for the Ember project. Resources will be shared from the filesPath directory. The root file is index.html

Link copied to clipboard
fun Route.file(remotePath: String, localPath: File)
fun Route.file(remotePath: String, localPath: String = remotePath)

Sets up routing to serve localPath file as remotePath

Link copied to clipboard
fun Route.files(folder: File)
fun Route.files(folder: String)

Sets up routing to serve all files from folder

Link copied to clipboard
fun SPAConfig.ignoreFiles(block: (path: String) -> Boolean)

Registers a block in ignoredFiles returns true if path should be ignored.

Link copied to clipboard
fun LastModifiedVersion(lastModified: FileTime): LastModifiedVersion

Construct LastModifiedVersion version from a FileTime instance

fun LastModifiedVersion(lastModified: ZonedDateTime): LastModifiedVersion

Construct LastModifiedVersion version from a ZonedDateTime instance

fun LastModifiedVersion(lastModified: Long): LastModifiedVersion

Construct LastModifiedVersion version from a Long instance

Link copied to clipboard
fun LocalFileContent(baseDir: File, relativePath: String, contentType: ContentType = ContentType.defaultForFilePath(relativePath)): LocalFileContent
fun LocalFileContent(baseDir: Path, relativePath: Path, contentType: ContentType = ContentType.defaultForFile(relativePath)): LocalFileContent

Creates an instance of LocalFileContent for a file designated by relativePath in a baseDir

Link copied to clipboard
fun Route.preCompressed(vararg types: CompressedFileType = CompressedFileType.values(), configure: Route.() -> Unit)

Support pre-compressed files in the file system only (not just any classpath resource)

Link copied to clipboard
fun SPAConfig.react(filesPath: String)

Creates an application configuration for the React project. Resources will be shared from the filesPath directory. The root file is index.html

Link copied to clipboard
fun ApplicationCall.resolveResource(path: String, resourcePackage: String? = null, classLoader: ClassLoader = application.environment.classLoader, mimeResolve: (String) -> ContentType = { ContentType.defaultForFileExtension(it) }): OutgoingContent?
Link copied to clipboard
fun Route.resource(remotePath: String, resource: String = remotePath, resourcePackage: String? = null)

Sets up routing to serve resource as remotePath in resourcePackage

Link copied to clipboard
fun resourceClasspathResource(url: URL, path: String, mimeResolve: (String) -> ContentType): OutgoingContent?

Attempt to find a local file or a file inside of zip. This is not required but very good to have to improve performance and unnecessary java.io.InputStream creation.

Link copied to clipboard
fun Route.resources(resourcePackage: String? = null)

Sets up routing to serve all resources in resourcePackage

Link copied to clipboard
fun Route.singlePageApplication(configBuilder: SPAConfig.() -> Unit = {})

Serves a single-page application. You can learn more from Serving single-page applications.

Link copied to clipboard
fun Route.static(configure: Route.() -> Unit): Route

Create a block for static content

fun Route.static(remotePath: String, configure: Route.() -> Unit): Route

Create a block for static content at specified remotePath

Link copied to clipboard
fun transformDefaultContent(call: ApplicationCall, value: Any): <ERROR CLASS>?

Default outgoing content transformation

Link copied to clipboard
fun SPAConfig.vue(filesPath: String)

Creates an application configuration for the Vue project. Resources will be shared from the filesPath directory. The root file is index.html

Properties

Link copied to clipboard
var Route.staticBasePackage: String?

Base package for relative resources calculations for static content

Link copied to clipboard
var Route.staticRootFolder: File?

Base folder for relative files calculations for static content

Link copied to clipboard
val SuppressionAttribute: <ERROR CLASS><Boolean>

Attribute that could be added to an application call to prevent it's response from being compressed