Skip to content

Commit

Permalink
httptransport: use compression middleware
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Oct 20, 2023
1 parent 0d2bf7e commit e97f6b3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion httptransport/discoveryhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"

"github.com/quay/clair/v4/internal/httputil"
"github.com/quay/clair/v4/middleware/compress"
)

//go:generate go run openapigen.go
Expand Down Expand Up @@ -46,7 +47,7 @@ func DiscoveryHandler(_ context.Context, prefix string, topt otelhttp.Option) ht
_, err = io.Copy(w, bytes.NewReader(openapiJSON))
})
inner = otelhttp.NewHandler(
discoverywrapper.wrap(prefix, inner),
compress.Handler(discoverywrapper.wrap(prefix, inner)),
"discovery",
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
topt,
Expand Down
3 changes: 2 additions & 1 deletion httptransport/indexer_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/quay/clair/v4/indexer"
"github.com/quay/clair/v4/internal/codec"
"github.com/quay/clair/v4/internal/httputil"
"github.com/quay/clair/v4/middleware/compress"
)

// NewIndexerV1 returns an http.Handler serving the Indexer V1 API rooted at
Expand All @@ -25,7 +26,7 @@ func NewIndexerV1(_ context.Context, prefix string, srv indexer.Service, topt ot
m := http.NewServeMux()
h := IndexerV1{
inner: otelhttp.NewHandler(
m,
compress.Handler(m),
"indexerv1",
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
topt,
Expand Down
3 changes: 2 additions & 1 deletion httptransport/matcher_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/quay/clair/v4/internal/codec"
"github.com/quay/clair/v4/internal/httputil"
"github.com/quay/clair/v4/matcher"
"github.com/quay/clair/v4/middleware/compress"
)

// NewMatcherV1 returns an http.Handler serving the Matcher V1 API rooted at
Expand All @@ -30,7 +31,7 @@ func NewMatcherV1(_ context.Context, prefix string, srv matcher.Service, indexer
m := http.NewServeMux()
h := MatcherV1{
inner: otelhttp.NewHandler(
m,
compress.Handler(m),
"matcherv1",
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
topt,
Expand Down
3 changes: 2 additions & 1 deletion httptransport/notification_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/quay/clair/v4/internal/codec"
"github.com/quay/clair/v4/internal/httputil"
"github.com/quay/clair/v4/middleware/compress"
"github.com/quay/clair/v4/notifier"
)

Expand All @@ -40,7 +41,7 @@ func NewNotificationV1(_ context.Context, prefix string, srv notifier.Service, t
m := http.NewServeMux()
h := NotificationV1{
inner: otelhttp.NewHandler(
m,
compress.Handler(m),
"notificationv1",
otelhttp.WithMessageEvents(otelhttp.ReadEvents, otelhttp.WriteEvents),
topt,
Expand Down

0 comments on commit e97f6b3

Please sign in to comment.