From e44e077c1fe15a7ad190c818c28b2025833a2b00 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 19 Aug 2024 10:56:23 +0200 Subject: [PATCH] Make gzip compression optional Signed-off-by: Knut Ahlers --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index ef4e1f3..4cc3a6d 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( var ( cfg = struct { + Gzip bool `flag:"gzip" default:"true" description:"Enable gzip compression"` Listen string `flag:"listen" default:":3000" description:"Port/IP to listen on"` LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"` RootDir string `flag:"root-dir,r" default:"" vardefault:"rootDir" description:"Where to store files / get files from"` @@ -59,7 +60,9 @@ func main() { router.PathPrefix("/").Methods(http.MethodPost, http.MethodPut).HandlerFunc(handlePut) var hdl http.Handler = router - hdl = httpHelper.GzipHandler(hdl) + if cfg.Gzip { + hdl = httpHelper.GzipHandler(hdl) + } hdl = httpHelper.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger()) server := &http.Server{