Package-level declarations

Types

Link copied to clipboard

An engine which runs an application.

Link copied to clipboard
Link copied to clipboard

Engine environment configuration builder

Engine environment configuration builder

Builder for configuring the environment of the Ktor application.

Engine environment configuration builder

Link copied to clipboard
class ApplicationEnvironmentImplNix(val log: Logger, val config: ApplicationConfig, val monitor: Events = Events()) : ApplicationEnvironment
class ApplicationEnvironmentImplNix(val log: Logger, val config: ApplicationConfig, val monitor: Events = Events()) : ApplicationEnvironment
Link copied to clipboard
abstract class BaseApplicationCall(val application: Application) : PipelineCall

Base class for implementing an PipelineCall.

Link copied to clipboard
abstract class BaseApplicationEngine(val environment: ApplicationEnvironment, monitor: Events, developmentMode: Boolean, val pipeline: EnginePipeline = defaultEnginePipeline(environment.config, developmentMode)) : ApplicationEngine

Base class for implementing ApplicationEngine

Link copied to clipboard

Base class for implementing PipelineRequest

Link copied to clipboard
Link copied to clipboard
class CommandLineConfig(val rootConfig: ServerConfig, val engineConfig: BaseApplicationEngine.Configuration)
Link copied to clipboard
object ConfigKeys
Link copied to clipboard
data class ConnectorType(val name: String)

Represents a type of a connector, e.g HTTP or HTTPS.

Link copied to clipboard
class DefaultUncaughtExceptionHandler(logger: () -> Logger) : CoroutineExceptionHandler

Handles all uncaught exceptions and logs errors with the specified logger ignoring CancellationException and IOException.

Link copied to clipboard

Represents an embedded server that hosts an application. It's an entry point to the application and handles the lifecycle of the application engine.

Link copied to clipboard
open class EngineConnectorBuilder(val type: ConnectorType = ConnectorType.HTTP) : EngineConnectorConfig

Mutable implementation of EngineConnectorConfig for building connectors programmatically

Link copied to clipboard

Represents a connector configuration.

Link copied to clipboard
class EnginePipeline(val developmentMode: Boolean = false) : Pipeline<Unit, PipelineCall>

Application engine pipeline. One usually don't need to install interceptors here unless your are writing your own engine implementation

Link copied to clipboard
class EngineSSLConnectorBuilder(var keyStore: KeyStore, var keyAlias: String, var keyStorePassword: () -> CharArray, var privateKeyPassword: () -> CharArray) : EngineSSLConnectorConfig

Mutable implementation of EngineSSLConnectorConfig for building connectors programmatically

Link copied to clipboard

Represents an SSL connector configuration.

Link copied to clipboard
class ShutDownUrl(val url: String, val exitCode: <Error class: unknown class>.() -> Int)

A plugin that allows you to configure a URL used to shut down the server. There are two ways to enable this plugin:

Functions

Link copied to clipboard
fun EmbeddedServer<*, *>.addShutdownHook(stop: () -> Unit)

Adds automatic application shutdown hooks management. Should be used before starting the server. Once application termination noticed, stop block will be executed. Please note that a shutdown hook only registered when the application is running. If the application is already stopped then there will be no hook and no stop function invocation possible. So stop block will be called once or never.

Link copied to clipboard

Creates an ApplicationEnvironment instance from command line arguments

Link copied to clipboard

Adds a non-secure connector to this engine environment

Link copied to clipboard

Default engine pipeline for all engines. Use it only if you are writing your own application engine implementation.

Link copied to clipboard

Map cause to the corresponding status code or null if no default exception mapping for this cause type

Link copied to clipboard

Creates an embedded server with the given factory, environment and configure script.

Creates an embedded server with the given factory, environment and configure script.

fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> embeddedServer(factory: ApplicationEngineFactory<TEngine, TConfiguration>, port: Int = 80, host: String = "0.0.0.0", watchPaths: List<String> = listOf(WORKING_DIRECTORY_PATH), module: Application.() -> Unit): EmbeddedServer<TEngine, TConfiguration>

Creates an embedded server with the given factory, listening on host:port.

Link copied to clipboard
fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> CoroutineScope.embeddedServer(factory: ApplicationEngineFactory<TEngine, TConfiguration>, vararg connectors: EngineConnectorConfig = arrayOf(), watchPaths: List<String> = listOf(WORKING_DIRECTORY_PATH), parentCoroutineContext: CoroutineContext = EmptyCoroutineContext, module: Application.() -> Unit): EmbeddedServer<TEngine, TConfiguration>

Creates an embedded server with the given factory, listening on given connectors.

fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> CoroutineScope.embeddedServer(factory: ApplicationEngineFactory<TEngine, TConfiguration>, port: Int = 80, host: String = "0.0.0.0", watchPaths: List<String> = listOf(WORKING_DIRECTORY_PATH), parentCoroutineContext: CoroutineContext = EmptyCoroutineContext, module: Application.() -> Unit): EmbeddedServer<TEngine, TConfiguration>

Creates an embedded server with the given factory, listening on host:port.

Link copied to clipboard
suspend fun handleFailure(call: ApplicationCall, error: Throwable)

Logs the error and responds with an appropriate error status code.

Link copied to clipboard
Link copied to clipboard
fun Job.launchOnCancellation(block: suspend () -> Unit): CompletableJob

Launch a coroutine with block body when either the parent job or the returned job is cancelled. It is important to complete or cancel the returned CompletableJob otherwise the parent job will be unable to complete successfully.

Link copied to clipboard

Loads common engine configuration parameters applicable to all engine types from the specified ApplicationConfig.

Link copied to clipboard
suspend fun logError(call: ApplicationCall, error: Throwable)

Logs the error with MDC setup.

Link copied to clipboard
inline fun <Error class: unknown class>.sslConnector(keyStore: KeyStore, keyAlias: String, noinline keyStorePassword: () -> CharArray, noinline privateKeyPassword: () -> CharArray, builder: EngineSSLConnectorBuilder.() -> Unit)

Adds a secure connector to this engine environment

Link copied to clipboard
fun <Error class: unknown class>.stop(gracePeriod: Long, timeout: Long, timeUnit: TimeUnit)

Stops this ApplicationEngine

Link copied to clipboard
fun ApplicationEngine.stopServerOnCancellation(application: Application, gracePeriodMillis: Long = 50, timeoutMillis: Long = 5000): CompletableJob

Stop server on job cancellation. The returned CompletableJob needs to be completed or cancelled.

Link copied to clipboard

Returns new instance of EngineConnectorConfig based on this with modified port

Returns new instance of EngineConnectorConfig based on this with modified port

Returns new instance of EngineConnectorConfig based on this with modified port