Defaults

The defaults() function provided by the practices module adds some useful concerns to your web server to enable features such as compression or client side caching. This way, you will have a well configured server instance without the need of adding everything by yourself.

Kotlin
val app = Layout.create()

Host.create()
    .handler(app)
    .defaults()
    .run()

If you would like to opt out of a default feature, or enable one that is off by default, you may pass a flag as needed:

Kotlin
val app = Layout.create()

Host.create()
    .handler(app)
    .defaults(compression = false, rangeSupport = true)
    .run()

defaults() accepts the following flags:

FlagDefaultEnables
compressiontrueCompression of response content.
decompressionfalseDecompression of request content.
secureUpgradetrueAutomatic upgrade of insecure requests.
strictTransporttrueHSTS via a Strict-Transport-Security header.
clientCachingtrueClient side caching via ETag validation.
rangeSupportfalsePartial responses for range requests.
preventSniffingfalseMIME type sniffing prevention via X-Content-Type-Options.