Defaults
The Defaults() method 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.
await Host.Create()
.Handler(...)
.Defaults()
.RunAsync();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:
await Host.Create()
.Handler(...)
.Defaults(compression: false, rangeSupport: true)
.RunAsync();Defaults() accepts the following flags:
| Flag | Default | Enables |
|---|---|---|
compression | true | Compression of response content. |
decompression | false | Decompression of request content. |
secureUpgrade | true | Automatic upgrade of insecure requests. |
strictTransport | true | HSTS via a Strict-Transport-Security header. |
clientCaching | true | Client side caching via ETag validation. |
rangeSupport | false | Partial responses for range requests. |
preventSniffing | false | MIME type sniffing prevention via X-Content-Type-Options. |