onCall
Specifies the block handler for every incoming PipelineCall.
This block is invoked for every incoming call even if the call is already handled by other handler. There you can handle the call in a way you want: add headers, change the response status, etc. You can also access the external state to calculate stats.
This example demonstrates how to create a plugin that appends a custom header to each response:
val CustomHeaderPlugin = createApplicationPlugin(name = "CustomHeaderPlugin") {
onCall { call ->
call.response.headers.append("X-Custom-Header", "Hello, world!")
}
}
Content copied to clipboard
Parameters
block
An action that needs to be executed when your application receives an HTTP call.