createApplicationPlugin

fun <PluginConfigT : Any> createApplicationPlugin(name: String, createConfiguration: () -> PluginConfigT, body: PluginBuilder<PluginConfigT>.() -> Unit): ApplicationPlugin<PluginConfigT>

Creates an ApplicationPlugin that can be installed into an Application.

The example below create a plugin that prints a requested URL each time your application receives a call:

val RequestLoggingPlugin = createApplicationPlugin("RequestLoggingPlugin") {
onCall { call ->
println(call.request.uri)
}
}

application.install(RequestLoggingPlugin)

You can learn more from Custom plugins.

Parameters

name

A name of a plugin that is used to get its instance.

createConfiguration

Defines how the initial PluginConfigT of your new plugin can be created. Note that it may be modified later when a user of your plugin calls Application.install.

body

Allows you to define handlers (onCall, onCallReceive, onCallRespond and so on) that can modify the behaviour of an Application where your plugin is installed.


fun createApplicationPlugin(name: String, body: PluginBuilder<Unit>.() -> Unit): ApplicationPlugin<Unit>

Creates an ApplicationPlugin that can be installed into an Application.

The example below create a plugin that prints a requested URL each time your application receives a call:

val RequestLoggingPlugin = createApplicationPlugin("RequestLoggingPlugin") {
onCall { call ->
println(call.request.uri)
}
}

application.install(RequestLoggingPlugin)

You can learn more from Custom plugins.

Parameters

name

A name of a plugin that is used to get an instance of the plugin installed to the Application.

body

Allows you to define handlers (onCall, onCallReceive, onCallRespond and so on) that can modify the behaviour of an Application where your plugin is installed.