Skip to content

Commit

Permalink
Serve GZipped static assets (#7788)
Browse files Browse the repository at this point in the history
  • Loading branch information
eladlachmi authored May 21, 2024
1 parent 8a8ab3f commit 29e0022
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ require (
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ahmetb/go-linq/v3 v3.2.0 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20200730104253-651201b0f516 // indirect
github.com/aws/aws-sdk-go v1.48.11 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4K
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/ui_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/NYTimes/gziphandler"
gomime "github.com/cubewise-code/go-mime"
"github.com/treeverse/lakefs/pkg/api/params"
gwerrors "github.com/treeverse/lakefs/pkg/gateway/errors"
Expand All @@ -33,7 +34,8 @@ func NewUIHandler(gatewayDomains []string, snippets []params.CodeSnippet) http.H
panic(err)
}
fileSystem := http.FS(injectedContent)
etagHandler := EtagMiddleware(injectedContent, http.StripPrefix("/", http.FileServer(fileSystem)))
gzipHandler := gziphandler.GzipHandler(http.FileServer(fileSystem))
etagHandler := EtagMiddleware(injectedContent, http.StripPrefix("/", gzipHandler))
return NewHandlerWithDefault(fileSystem, etagHandler, gatewayDomains)
}

Expand Down

0 comments on commit 29e0022

Please sign in to comment.