Package io.ktor.server.application

Types

Link copied to clipboard

Contains handlers executed after the same handler is finished for all otherPlugins.

Link copied to clipboard
class Application(environment: ApplicationEnvironment) : ApplicationCallPipeline

Represents configured and running web application, capable of handling requests. It is also the application coroutine scope that is cancelled immediately at application stop so useful for launching background coroutines.

Link copied to clipboard
interface ApplicationCall

Represents a single act of communication between a client and server.

Link copied to clipboard
open class ApplicationCallPipeline(developmentMode: Boolean, environment: ApplicationEnvironment?)

Pipeline configuration for executing ApplicationCall instances.

Link copied to clipboard
interface ApplicationCallWithContext : ApplicationCall
Link copied to clipboard
expect interface ApplicationEnvironment

Represents an environment in which Application runs

actual interface ApplicationEnvironment

Represents an environment in which Application runs

actual interface ApplicationEnvironment
Link copied to clipboard
typealias ApplicationEvents = <ERROR CLASS>

Provides events for Application lifecycle.

Link copied to clipboard
interface ApplicationPlugin<in TPipeline, out TConfiguration : Any, TPlugin : Any> : Plugin<TPipeline, TConfiguration, TPlugin>

Defines a Plugin that is installed into Application

Link copied to clipboard
abstract class ApplicationPluginBuilder<PluginConfig : Any> : PluginBuilder<PluginConfig>

Utility class to build an ApplicationPlugin instance.

Link copied to clipboard

Contains handlers executed before the same handler is finished for all otherPlugins.

Link copied to clipboard
open class CallContext<PluginConfig : Any>

The context associated with the call that is currently being processed by server. Every call handler (ApplicationPluginBuilder.onCall, ApplicationPluginBuilder.onCallReceive, ApplicationPluginBuilder.onCallRespond, and so on) of your plugin has a derivative of CallContext as a receiver.

Link copied to clipboard
object CallFailed : Hook<suspend (call: ApplicationCall, cause: Throwable) -> Unit>
Link copied to clipboard
open class DuplicateApplicationPluginException(message: String) : Exception

Thrown on an attempt to install the plugin with the same key as for the already installed plugin

Link copied to clipboard
class DuplicatePluginException(message: String) : DuplicateApplicationPluginException

Thrown on an attempt to install the plugin with the same key as for the already installed plugin

Link copied to clipboard
typealias EventDefinition<T> = <ERROR CLASS><T>

Definition of an event. Event is used as a key so both hashCode and equals need to be implemented properly. Inheriting of this class is an experimental plugin. Instantiate directly if inheritance not necessary.

Link copied to clipboard
typealias EventHandler<T> = <ERROR CLASS><T>

Specifies signature for the event handler.

Link copied to clipboard
interface Hook<HookHandler>

Represents a hook that can be registered in ApplicationPluginBuilder.

Link copied to clipboard
class InvalidBodyException(message: String) : Exception

An exception that is thrown when the current body in the HTTP pipeline is invalid.

Link copied to clipboard
class MissingApplicationPluginException(key: <ERROR CLASS><out <ERROR CLASS>>) : IllegalStateException

Thrown on an attempt to access the plugin that is not yet installed

Link copied to clipboard
class OnCallContext<PluginConfig : Any> : CallContext<PluginConfig>

A context associated with the call handling by your application. OnCallContext is a receiver for ApplicationPluginBuilder.onCall handler of your ApplicationPluginBuilder.

Link copied to clipboard
class OnCallReceiveContext<PluginConfig : Any> : CallContext<PluginConfig>

A context associated with the call.receive() action. Allows you to transform the received body. OnCallReceiveContext is a receiver for ApplicationPluginBuilder.onCallReceive handler of your ApplicationPluginBuilder.

Link copied to clipboard
interface OnCallRespond<PluginConfig : Any>

Descendents of OnCallReceive allow you to extend the process of sending a response to the client.

Link copied to clipboard

A context associated with the onCallRespond.afterTransform {...} handler. Allows you to transform the response binary data. OnCallRespondAfterTransformContext is a receiver for OnCallRespond.afterTransform handler of your ApplicationPluginBuilder.

Link copied to clipboard
class OnCallRespondContext<PluginConfig : Any> : CallContext<PluginConfig>

A context associated with the call.respond() action. Allows you to transform the response body. OnCallRespondContext is a receiver for ApplicationPluginBuilder.onCallRespond handler of your ApplicationPluginBuilder.

Link copied to clipboard
interface Plugin<in TPipeline, out TConfiguration : Any, TPlugin : Any>

Defines an installable Plugin

Link copied to clipboard
interface PluginBuilder<PluginConfig : Any>

A builder that is available inside a plugin creation block. You can use this builder to hook in various steps of request processing.

Link copied to clipboard
class PluginInstance

An instance of the plugin installed to your application

Link copied to clipboard
sealed class RelativePluginBuilder<PluginConfig : Any> : PluginBuilder<PluginConfig>

A PluginBuilder that allows you to insert the currentPlugin actions before/after otherPlugins.

Link copied to clipboard

Defines a Plugin that can be installed into Route

Link copied to clipboard

Utility class to build a RouteScopedPlugin instance.

Link copied to clipboard
object Shutdown : Hook<(Application) -> Unit>

Represents a hook that is executed when the server is shutting down.

Link copied to clipboard
class TransformBodyContext(requestedType: <ERROR CLASS>?)

Contains type information about the current request or response body when performing a transformation.

Functions

Link copied to clipboard

Creates a ApplicationPlugin that can be installed into Application.

Creates an ApplicationPlugin that can be installed into Application.

Link copied to clipboard

Creates a RouteScopedPlugin that can be installed into Application.

fun <PluginConfigT : Any> createRouteScopedPlugin(name: String, createConfiguration: () -> PluginConfigT, body: ApplicationPluginBuilder<PluginConfigT>.() -> Unit): RouteScopedPlugin<PluginConfigT, PluginInstance>

Creates a RouteScopedPlugin that can be installed into io.ktor.server.routing.Route.

Link copied to clipboard
fun <F : Any> Route.findPluginInRoute(plugin: Plugin<*, *, F>): F?
Link copied to clipboard
fun <P : Route, B : Any, F : Any> P.install(plugin: ApplicationPlugin<P, B, F>, configure: B.() -> Unit = {}): F
fun <P, B : Any, F : Any> P.install(plugin: Plugin<P, B, F>, configure: B.() -> Unit = {}): F

Installs plugin into this pipeline, if it is not yet installed

Link copied to clipboard
fun <A, F : Any> A.plugin(plugin: Plugin<*, *, F>): F

Gets a plugin instance for this pipeline, or fails with MissingApplicationPluginException if the plugin is not installed.

Link copied to clipboard
fun <A, F : Any> A.pluginOrNull(plugin: Plugin<*, *, F>): F?

Returns plugin instance for this pipeline, or null if plugin is not installed

Link copied to clipboard
fun <A, B : Any, F : Any> A.uninstall(plugin: Plugin<A, B, F>)

Uninstalls plugin from the pipeline

Link copied to clipboard
fun <A> A.uninstallAllPlugins()

Uninstalls all plugins from the pipeline

Link copied to clipboard
fun <A, F : Any> A.uninstallPlugin(key: <ERROR CLASS><F>)

Uninstalls plugin specified by key from the pipeline

Properties

Link copied to clipboard
val <ERROR CLASS><out <ERROR CLASS>, ApplicationCall>.application: Application

Current application for the context

Link copied to clipboard
val ApplicationStarted: <ERROR CLASS><T>

Event definition for Application Started event

Link copied to clipboard
val ApplicationStarting: <ERROR CLASS><T>

Event definition for Application Starting event

Link copied to clipboard
val ApplicationStopped: <ERROR CLASS><T>

Event definition for Application Stopped event

Link copied to clipboard
val ApplicationStopping: <ERROR CLASS><T>

Event definition for Application Stopping event

Link copied to clipboard
val ApplicationStopPreparing: <ERROR CLASS><T>

Event definition for an event that is fired when the application is going to stop

Link copied to clipboard
val <ERROR CLASS><out <ERROR CLASS>, ApplicationCall>.call: ApplicationCall

Current call for the context

Link copied to clipboard
val ApplicationConfig.host: String

The host address of the currently running application, as defined by the configuration at start-up.

Link copied to clipboard
val ApplicationCall.isHandled: Boolean

Indicates if the response was sent.

Link copied to clipboard
val Application.log: <ERROR CLASS>

Convenience property to access log from application

Link copied to clipboard
val <A> A.pluginRegistry: <ERROR CLASS>

Returns existing plugin registry or register and returns a new one

Link copied to clipboard
val ApplicationConfig.port: Int

The port the current application is running on, as defined by the configuration at start-up.