Response compression for the Website service (#7)
This PR contains the work done to add response compression to the Website service by registering the `ResponseCompressionMiddleware` middleware so responses are compressed when the client advertises support and the body exceeds a minimum size. To provide further details about the work done: * Added the **HummingbirdCompression** package dependency. * Integrated the `ResponseCompressionMiddleware` middleware into the router, ahead of the not-found and static file middleware. * Made the `minimum-response-size-to-compress` threshold configurable, with a default. Reviewed-on: rock-n-code/loud-amsterdam#7 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit is contained in:
@@ -10,6 +10,11 @@ extension AbsoluteConfigKey {
|
||||
/// The absolute configuration key for the max-age, in seconds, applied to all other static files.
|
||||
public static let maxAgeDefault: AbsoluteConfigKey = .init(.Cache.maxAgeDefault)
|
||||
}
|
||||
/// A namespace for the response compression configuration keys, as absolute keys.
|
||||
public enum Compression {
|
||||
/// The absolute configuration key for the minimum response body size, in bytes, before compression is applied.
|
||||
public static let minResponseSize: AbsoluteConfigKey = .init(.Compression.minResponseSize)
|
||||
}
|
||||
/// A namespace for the HTTP server configuration keys, as absolute keys.
|
||||
public enum HTTP {
|
||||
/// The absolute configuration key for the host the server binds to.
|
||||
|
||||
Reference in New Issue
Block a user