Browse Source

httpd: reuse the same compressor among bindings

Nicola Murino 4 years ago
parent
commit
d32b195a57
1 changed files with 2 additions and 1 deletions
  1. 2 1
      httpd/server.go

+ 2 - 1
httpd/server.go

@@ -21,6 +21,8 @@ import (
 	"github.com/drakkan/sftpgo/version"
 )
 
+var compressor = middleware.NewCompressor(5)
+
 type httpdServer struct {
 	binding         Binding
 	staticFilesPath string
@@ -398,7 +400,6 @@ func (s *httpdServer) initializeRouter() {
 			})
 
 			router.Group(func(router chi.Router) {
-				compressor := middleware.NewCompressor(5)
 				router.Use(compressor.Handler)
 				fileServer(router, webStaticFilesPath, http.Dir(s.staticFilesPath))
 			})