createRouteScopedPlugin

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

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

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

route("index") {
install(RequestLoggingPlugin)
}

You can learn more from Custom plugins.

Parameters

name

A name of a plugin that is used to get its instance when it is installed to io.ktor.server.routing.Routing.

createConfiguration

Defines how the initial PluginConfigT of your new plugin can be created. Please note that it may be modified later when a user of your plugin calls 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 a RouteScopedPlugin that can be installed into a io.ktor.server.routing.RouteNode.

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

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

route("index") {
install(RequestLoggingPlugin)
}

You can learn more from Custom plugins.

Parameters

name

A name of a plugin that is used to get its instance when it is installed to io.ktor.server.routing.Routing.

configurationPath

is path in configuration file to configuration of this plugin.

createConfiguration

Defines how the initial PluginConfigT of your new plugin can be created. Please note that it may be modified later when a user of your plugin calls 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 a RouteScopedPlugin that can be installed into a io.ktor.server.routing.RouteNode.

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

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

route("index") {
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 io.ktor.server.routing.RouteNode.

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.