Package io.ktor.server.engine

Types

Link copied to clipboard
interface ApplicationEngine

Engine which runs an application

Link copied to clipboard
interface ApplicationEngineEnvironment : ApplicationEnvironment

Represents an environment in which engine runs.

Link copied to clipboard
class ApplicationEngineEnvironmentBuilder

Engine environment configuration builder

Link copied to clipboard
class ApplicationEngineEnvironmentReloading(classLoader: ClassLoader, log: Logger, config: ApplicationConfig, connectors: List<EngineConnectorConfig>, modules: List<Application.() -> Unit>, watchPaths: List<String>, parentCoroutineContext: CoroutineContext, rootPath: String, developmentMode: Boolean) : ApplicationEngineEnvironment

Implements ApplicationEngineEnvironment by loading an Application from a folder or jar.

Link copied to clipboard

Factory interface for creating ApplicationEngine instances

Link copied to clipboard
abstract class BaseApplicationCall(application: Application) : ApplicationCall

Base class for implementing an ApplicationCall.

Link copied to clipboard
abstract class BaseApplicationEngine(environment: ApplicationEngineEnvironment, pipeline: EnginePipeline) : ApplicationEngine

Base class for implementing ApplicationEngine

Link copied to clipboard
abstract class BaseApplicationRequest(call: ApplicationCall) : ApplicationRequest

Base class for implementing ApplicationRequest

Link copied to clipboard
abstract class BaseApplicationResponse(call: ApplicationCall) : ApplicationResponse

Base class for implementing an ApplicationResponse

Link copied to clipboard
data class ConnectorType(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
annotation class EngineAPI

API marked with this annotation is not intended to be used by end users unless a custom server engine implementation is required

Link copied to clipboard
open class EngineConnectorBuilder(type: ConnectorType) : EngineConnectorConfig

Mutable implementation of EngineConnectorConfig for building connectors programmatically

Link copied to clipboard
interface EngineConnectorConfig

Represents a connector configuration.

Link copied to clipboard
class EnginePipeline(developmentMode: Boolean) : Pipeline<Unit, ApplicationCall>

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(keyStore: KeyStore, keyAlias: String, keyStorePassword: () -> CharArray, privateKeyPassword: () -> CharArray) : EngineConnectorBuilder, EngineSSLConnectorConfig

Mutable implementation of EngineSSLConnectorConfig for building connectors programmatically

Link copied to clipboard
interface EngineSSLConnectorConfig : EngineConnectorConfig

Represents an SSL connector configuration.

Link copied to clipboard
class ShutDownUrl(url: String, exitCode: ApplicationCall.() -> Int)

Shutdown URL feature. It stops application when requested particular url

Functions

Link copied to clipboard
fun ApplicationEngine.addShutdownHook(stop: () -> Unit)

Adds automatic JVM shutdown hooks management. Should be used before starting the engine. Once JVM 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
fun commandLineEnvironment(args: Array<String>): ApplicationEngineEnvironment

Creates an ApplicationEngineEnvironment instance from command line arguments

Link copied to clipboard
inline fun ApplicationEngineEnvironmentBuilder.connector(builder: EngineConnectorBuilder.() -> Unit)

Adds a non-secure connector to this engine environment

Link copied to clipboard
fun defaultEnginePipeline(environment: ApplicationEnvironment): EnginePipeline

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

Link copied to clipboard
fun defaultExceptionStatusCode(cause: Throwable): HttpStatusCode?

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

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), configure: TConfiguration.() -> Unit = {}, module: Application.() -> Unit): TEngine
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, configure: TConfiguration.() -> Unit = {}, module: Application.() -> Unit): TEngine

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

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

Default receive transformation

Default send transformation

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

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

Link copied to clipboard
fun BaseApplicationEngine.Configuration.loadCommonConfiguration(deploymentConfig: ApplicationConfig)

Load engine's configuration suitable for all engines from deploymentConfig

Link copied to clipboard
suspend fun logError(call: ApplicationCall, error: Throwable)
Link copied to clipboard
inline fun ApplicationEngineEnvironmentBuilder.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 ApplicationEngine.stop(gracePeriod: Long, timeout: Long, timeUnit: TimeUnit)
Link copied to clipboard
fun ApplicationEngine.stopServerOnCancellation(): CompletableJob

Stop server on job cancellation. The returned deferred need to be completed or cancelled.