Structure
ResponseCompressionMiddleware
struct ResponseCompressionMiddleware
Overview
This is useful when a set of static routes does not need compression, or a set of dynamic routes does.
When the HTTPServer.Configuration.ResponseCompressionConfiguration is set to be disabled by default, HTTPHeaders/ResponseCompression/enable can be set to explicitly enable compression. Likewise, when the configuration is set to be enabled by default, HTTPHeaders/ResponseCompression/disable can be set to explicitly disable compression.
To ignore a preference a downstream middleware (ie. closer to the root route than to the original response) may propose in favor of the server defaults, use HTTPHeaders/ResponseCompression/useDefault.
Note
Response compression is only actually used if the client indicates it supports it via an Accept header.
Topics
Initializers
init(override:force:)Initialize a response compression middleware with an override.
Instance Properties
responseCompressionOverrideThe response compression override to use over the base configuration.shouldForceA flag to force the override atop whatever the response or output of middleware that process the response before this one.
Instance Methods
respond(to:chainingTo:)Called with eachRequestthat passes through this middleware.
Relationships
Conforms To
AsyncMiddlewareMiddlewareSwift.SendableSwift.SendableMetatype