Static Methodvapor 4.106.2Vapor
enabled(initialByteBufferCapacity:disallowedTypes:allowRequestOverrides:)
Enables compression by default, but offers options to dissallow it for the specified types.
HTTPServerConfiguration+ResponseCompressionConfiguration.swift:90static func enabled(initialByteBufferCapacity: Int = defaultInitialByteBufferCapacity, disallowedTypes: HTTPMediaTypeSet = .incompressible, allowRequestOverrides: Bool = true) -> HTTPServer.Configuration.ResponseCompressionConfiguration
Parameters
- initialByteBufferCapacity
The initial buffer capacity to use when instanciating the compressor.
- disallowedTypes
The types to prevent from being compressed. If unspecified, incompressible types will match, thus disabling compression for media types unless explicitly overriden. Specify
none
to enable compression for all types by default.- allowRequestOverrides
Allow routes and requests to explicitely disable compression. If unspecified, responses will be compressed by default unless routes or responses explicitely disable it. See
ResponseCompressionMiddleware
for more information.
Returns
A response compression configuration.
Other members in extension
Type members
static let defaultInitialByteBufferCapacity: Int
The default initial byte buffer capacity to use for the compressor if none is specified.
static var disabled: `Self`
Disables compression for all content types unless a route overrides the preference. This is the default.
static var enabled: `Self`
Enables compression by default, dissallowing already compressed types such as images or video, unless a route overrides the preference.
static var enabledForCompressibleTypes: `Self`
Disables compression by default, but allows easily compressible types such as text, unless a route overrides the preference.
static var forceDisabled: `Self`
Disables compression unconditionally.
static func disabled(initialByteBufferCapacity: Int, allowedTypes: HTTPMediaTypeSet, allowRequestOverrides: Bool
) -> HTTPServer.Configuration.ResponseCompressionConfiguration Disables compression by default, but offers options to allow it for the specified types.
Show obsolete interfaces (1)
Hide obsolete interfaces
static func enabled(initialByteBufferCapacity: Int
) -> HTTPServer.Configuration.ResponseCompressionConfiguration Enables compression with custom configuration.
Instance members
var allowRequestOverrides: Bool
Allow routes and requests to explicitely override compression.
var initialByteBufferCapacity: Int
The initial buffer capacity to use when instanciating the compressor.