diff --git a/Makefile b/Makefile index a22ef9f8..050a33ba 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,7 @@ KIND_CLUSTER_IMAGE := kindest/node:v1.30.0@sha256:047357ac0cfea04663786a612ba1ea .PHONY: help help: ## Display this help. awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +.DEFAULT_GOAL := help ##@ Development diff --git a/go.mod b/go.mod index 2dc5eff6..e6612021 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/operator-framework/catalogd go 1.22.0 require ( + github.com/NYTimes/gziphandler v1.1.1 github.com/blang/semver/v4 v4.0.0 github.com/containerd/containerd v1.7.18 github.com/go-logr/logr v1.4.1 diff --git a/go.sum b/go.sum index 6176a561..98c0b228 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/hcsshim v0.12.0-rc.3 h1:5GNGrobGs/sN/0nFO21W9k4lFn+iXXZAE8fCZbmdRak= github.com/Microsoft/hcsshim v0.12.0-rc.3/go.mod h1:WuNfcaYNaw+KpCEsZCIM6HCEmu0c5HfXpi+dDSmveP0= +github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= +github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= diff --git a/pkg/storage/localdir.go b/pkg/storage/localdir.go index a34924c2..002655b7 100644 --- a/pkg/storage/localdir.go +++ b/pkg/storage/localdir.go @@ -9,6 +9,8 @@ import ( "os" "path/filepath" + "github.com/NYTimes/gziphandler" + "github.com/operator-framework/operator-registry/alpha/declcfg" ) @@ -56,7 +58,7 @@ func (s LocalDir) ContentURL(catalog string) string { func (s LocalDir) StorageServerHandler() http.Handler { mux := http.NewServeMux() - mux.Handle(s.BaseURL.Path, http.StripPrefix(s.BaseURL.Path, http.FileServer(http.FS(&filesOnlyFilesystem{os.DirFS(s.RootDir)})))) + mux.Handle(s.BaseURL.Path, gziphandler.GzipHandler(http.StripPrefix(s.BaseURL.Path, http.FileServer(http.FS(&filesOnlyFilesystem{os.DirFS(s.RootDir)}))))) return mux }