Make gzip compression optional
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9f5882831a
commit
e44e077c1f
1 changed files with 4 additions and 1 deletions
3
main.go
3
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
|
||||
if cfg.Gzip {
|
||||
hdl = httpHelper.GzipHandler(hdl)
|
||||
}
|
||||
hdl = httpHelper.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger())
|
||||
|
||||
server := &http.Server{
|
||||
|
|
Loading…
Reference in a new issue