Package io.ktor.server.application

Types

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

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

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
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

Defines a Plugin that is installed into Application.

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

Defines a Plugin that is installed into Application.

Link copied to clipboard

Defines a Plugin that can be installed into a Route.

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 (PluginBuilder.onCall, PluginBuilder.onCallReceive, PluginBuilder.onCallRespond, and so on) of your plugin has a derivative of CallContext as a receiver.

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>

A hook that can be registered in PluginBuilder.

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, CopyableThrowable<MissingApplicationPluginException>

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 PluginBuilder.onCall handler of your PluginBuilder.

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 PluginBuilder.onCallReceive handler of your PluginBuilder.

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 PluginBuilder.onCallRespond handler of your PluginBuilder.

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

Defines an installable Plugin.

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

A utility class to build an ApplicationPlugin instance.

Link copied to clipboard
class PluginInstance

An instance of the plugin installed to your application.

Link copied to clipboard

Defines a Plugin that can be installed into Route

Link copied to clipboard
typealias RouteScopedPluginBuilder<PluginConfig> = PluginBuilder<PluginConfig>

Utility class to build a RouteScopedPlugin instance.

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
fun createApplicationPlugin(name: String, body: PluginBuilder<Unit>.() -> Unit): ApplicationPlugin<Unit>
fun <PluginConfigT : Any> createApplicationPlugin(name: String, createConfiguration: () -> PluginConfigT, body: PluginBuilder<PluginConfigT>.() -> Unit): ApplicationPlugin<PluginConfigT>

Creates an ApplicationPlugin that can be installed into an Application.

Link copied to clipboard
fun createRouteScopedPlugin(name: String, body: PluginBuilder<Unit>.() -> Unit): RouteScopedPlugin<Unit>
fun <PluginConfigT : Any> createRouteScopedPlugin(name: String, createConfiguration: () -> PluginConfigT, body: PluginBuilder<PluginConfigT>.() -> Unit): RouteScopedPlugin<PluginConfigT>

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

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

Finds the plugin F in the current Route. If not found, search in the parent Route.

Link copied to clipboard
fun <P : Route, B : Any, F : Any> P.install(plugin: BaseApplicationPlugin<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 a 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 a plugin instance for this pipeline, or null if the plugin is not installed.

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

Uninstalls a 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 a 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 a response is 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 the existing plugin registry or registers 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.

Link copied to clipboard
var ApplicationCall.receiveType: <ERROR CLASS>

The TypeInfo recorded from the last call.receive() call.