diff --git a/Package.swift b/Package.swift index 2b2cf92..d63b3ce 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"), - .package(url: "https://github.com/adam-fowler/compress-nio.git", from: "1.3.0"), + .package(url: "https://github.com/adam-fowler/compress-nio.git", from: "1.4.0"), .package(url: "https://github.com/apple/swift-nio.git", from: "2.32.1"), ], targets: [ diff --git a/Sources/HummingbirdCompression/ResponseCompressionMiddleware.swift b/Sources/HummingbirdCompression/ResponseCompressionMiddleware.swift index 42f89a4..cdf21c1 100644 --- a/Sources/HummingbirdCompression/ResponseCompressionMiddleware.swift +++ b/Sources/HummingbirdCompression/ResponseCompressionMiddleware.swift @@ -33,21 +33,19 @@ public struct ResponseCompressionMiddleware: RouterMidd /// - Parameters: /// - windowSize: Compression window size /// - minimumResponseSizeToCompress: Minimum size of response before applying compression - /// - zlibCompressionLevel: zlib compression level to use. Value between 0 and 9 where 1 is fastest, 9 is best compression and - /// 0 is no compression. - /// - zlibMemoryLevel: Amount of memory to use when compressing. Less memory will mean the compression will take longer - /// and compression level will be reduced. Value between 1 - 9 where 1 is least amount of memory. + /// - zlibCompressionLevel: zlib compression level. + /// - zlibMemoryLevel: Amount of memory to allocated for compression state. public init( windowSize: Int = 32768, minimumResponseSizeToCompress: Int = 1024, - zlibCompressionLevel: Int? = nil, - zlibMemoryLevel: Int? = nil + zlibCompressionLevel: ZlibConfiguration.CompressionLevel = .defaultCompressionLevel, + zlibMemoryLevel: ZlibConfiguration.MemoryLevel = .defaultMemoryLevel ) { self.windowSize = windowSize self.minimumResponseSizeToCompress = minimumResponseSizeToCompress self.zlibConfiguration = .init( - compressionLevel: numericCast(zlibCompressionLevel ?? -1), // -1 indicates use the default compression level set by the library - memoryLevel: numericCast(zlibMemoryLevel ?? 8) // 8 is the default value for the library + compressionLevel: zlibCompressionLevel, + memoryLevel: zlibMemoryLevel ) }