Make gzip compression optional
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9f5882831a
commit
e44e077c1f
5
main.go
5
main.go
@ -15,6 +15,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
cfg = struct {
|
cfg = struct {
|
||||||
|
Gzip bool `flag:"gzip" default:"true" description:"Enable gzip compression"`
|
||||||
Listen string `flag:"listen" default:":3000" description:"Port/IP to listen on"`
|
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)"`
|
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"`
|
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)
|
router.PathPrefix("/").Methods(http.MethodPost, http.MethodPut).HandlerFunc(handlePut)
|
||||||
|
|
||||||
var hdl http.Handler = router
|
var hdl http.Handler = router
|
||||||
hdl = httpHelper.GzipHandler(hdl)
|
if cfg.Gzip {
|
||||||
|
hdl = httpHelper.GzipHandler(hdl)
|
||||||
|
}
|
||||||
hdl = httpHelper.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger())
|
hdl = httpHelper.NewHTTPLogHandlerWithLogger(hdl, logrus.StandardLogger())
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
|
Loading…
Reference in New Issue
Block a user