Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.96 KB

default_headers.md

File metadata and controls

49 lines (37 loc) · 1.96 KB

Required dependencies: io.ktor:%artifact_name%

The %plugin_name% plugin adds the standard Server and Date headers into each response. Moreover, you can provide additional default headers and override the Server header.

Add dependencies {id="add_dependencies"}

Install %plugin_name% {id="install_plugin"}

The %plugin_name% plugin adds the Server and Date headers into each response. If necessary, you can override the Server, as described in .

Add additional headers {id="add"}

To customize a list of default headers, pass a desired header to install by using the header(name, value) function. The name parameter accepts an HttpHeaders value, for example:

    install(DefaultHeaders) {
        header(HttpHeaders.ETag, "7c876b7e")
    }

To add a custom header, pass its name as a string value:

    install(DefaultHeaders) {
        header("Custom-Header", "Some value")
    }

Override headers {id="override"}

To override the Server header, use a corresponding HttpHeaders value:

    install(DefaultHeaders) {
        header(HttpHeaders.Server, "Custom")
    }

Note that the Date header is cached due to performance reasons and cannot be overridden by using %plugin_name%. If you need to override it, do not install the %plugin_name% plugin and use route interception instead.