createApplicationPlugin

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

Creates an ApplicationPlugin that can be installed into an Application.

The example below creates 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.

configurationPath

is path in configuration file to configuration of this plugin.

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.


Creates an ApplicationPlugin that can be installed into an Application.

The example below creates 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.


Creates an ApplicationPlugin that can be installed into an Application.

The example below creates 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.