on

fun <HookHandler> on(hook: Hook<HookHandler>, handler: HookHandler)

Specifies a handler for a specific hook. A hook can be a specific place in time or event during the request processing like application shutdown, an exception during call processing, etc.

See also

Example:

val ResourceManager = createApplicationPlugin("ResourceManager") {
val resources: List<Closeable> = TODO()

on(MonitoringEvent(ApplicationStopped)) {
resources.forEach { it.close() }
}
}