From 5a32fb0ab9e2d93c400e9c9e170ff3346987e1d8 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Thu, 9 May 2024 21:02:50 +0100 Subject: [PATCH] Update README --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7898808..df1bc18 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,9 @@ Adds request decompression and response compression to Hummingbird ## Usage ```swift -let app = HBApplication() -// run response compression on application thread pool when buffer is -// larger than 32768 bytes otherwise run it on the eventloop -app.addResponseCompression(execute: .onThreadPool(threshold: 32768)) -// run request decompression on eventloop with no limit to the size -// of data that can be decompressed -app.addRequestDecompression(execute: .onEventLoop, limit: .none) +let router = Router() +router.middlewares.add(RequestDecompressionMiddleware()) +router.middlewares.add(ResponseCompressionMiddleware(minimumResponseSizeToCompress: 512)) ``` -Adding request decompression means when a request comes in with header `content-encoding` set to `gzip` or `deflate` the server will attempt to decompress the request body. Adding response compression means when a request comes in with header `accept-encoding` set to `gzip` or `deflate` the server will compression the response body. +Adding request decompression middleware means when a request comes in with header `content-encoding` set to `gzip` or `deflate` the server will attempt to decompress the request body. Adding response compression means when a request comes in with header `accept-encoding` set to `gzip` or `deflate` the server will compression the response body.