feat: gzip static resources (#6258)

This commit is contained in:
Dmitry Salakhov
2021-12-13 22:34:55 +13:00
committed by GitHub
parent 76916b0ad6
commit eb517c2e12
3 changed files with 12 additions and 4 deletions

View File

@@ -3,6 +3,8 @@ package file
import (
"net/http"
"strings"
"github.com/gorilla/handlers"
)
// Handler represents an HTTP API handler for managing static files.
@@ -13,8 +15,11 @@ type Handler struct {
// NewHandler creates a handler to serve static files.
func NewHandler(assetPublicPath string) *Handler {
h := &Handler{
Handler: http.FileServer(http.Dir(assetPublicPath)),
Handler: handlers.CompressHandler(
http.FileServer(http.Dir(assetPublicPath)),
),
}
return h
}