Enable gzip compression on assets (#1150)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2021-10-26 18:20:26 -07:00
committed by GitHub
parent 6f13cbaec1
commit bbe87ecd59
4 changed files with 13 additions and 3 deletions

1
go.mod
View File

@@ -15,6 +15,7 @@ require (
github.com/go-openapi/validate v0.20.2
github.com/gorilla/websocket v1.4.2
github.com/jessevdk/go-flags v1.4.0
github.com/klauspost/compress v1.13.6 // indirect
github.com/minio/cli v1.22.0
github.com/minio/direct-csi v1.3.5-0.20210601185811-f7776f7961bf
github.com/minio/kes v0.11.0

2
go.sum
View File

@@ -764,6 +764,8 @@ github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8=
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=

View File

@@ -24,6 +24,8 @@ import (
"net/http"
"strings"
"github.com/klauspost/compress/gzhttp"
"github.com/minio/console/restapi"
"github.com/unrolled/secure"
@@ -155,7 +157,7 @@ func proxyMiddleware(next http.Handler) http.Handler {
func setupGlobalMiddleware(handler http.Handler) http.Handler {
// handle cookie or authorization header for session
next := AuthenticationMiddleware(handler)
// serve static files
// proxy requests
next = proxyMiddleware(next)
// serve static files
next = restapi.FileServerMiddleware(next)
@@ -185,5 +187,6 @@ func setupGlobalMiddleware(handler http.Handler) http.Handler {
IsDevelopment: false,
}
secureMiddleware := secure.New(secureOptions)
return secureMiddleware.Handler(next)
next = secureMiddleware.Handler(next)
return gzhttp.GzipHandler(next)
}

View File

@@ -31,6 +31,8 @@ import (
"strings"
"time"
"github.com/klauspost/compress/gzhttp"
portal_ui "github.com/minio/console/portal-ui"
"github.com/minio/pkg/mimedb"
@@ -186,7 +188,9 @@ func setupGlobalMiddleware(handler http.Handler) http.Handler {
IsDevelopment: false,
}
secureMiddleware := secure.New(secureOptions)
return RejectS3Middleware(secureMiddleware.Handler(next))
next = secureMiddleware.Handler(next)
gnext := gzhttp.GzipHandler(next)
return RejectS3Middleware(gnext)
}
// RejectS3Middleware will reject requests that have AWS S3 specific headers.