MCPcopy Create free account
hub / github.com/quay/clair / Handler

Function Handler

middleware/compress/handler.go:26–53  ·  view source on GitHub ↗

Handler wraps the provided http.Handler and provides transparent body compression based on a Request's "Accept-Encoding" header. Each handler instance pools its own compressors.

(next http.Handler)

Source from the content-addressed store, hash-verified

24//
25// Each handler instance pools its own compressors.
26func Handler(next http.Handler) http.Handler {
27 h := handler{
28 next: next,
29 }
30 h.zstd.New = func() interface{} {
31 w, err := zstd.NewWriter(nil, zstd.WithEncoderLevel(zstd.SpeedFastest))
32 if err != nil {
33 panic(err)
34 }
35 return w
36 }
37 h.gzip.New = func() interface{} {
38 w, err := gzip.NewWriterLevel(nil, gzip.BestSpeed)
39 if err != nil {
40 panic(err)
41 }
42 return w
43 }
44 h.flate.New = func() interface{} {
45 w, err := flate.NewWriter(nil, flate.BestSpeed)
46 if err != nil {
47 panic(err)
48 }
49 return w
50 }
51
52 return &h
53}
54
55var _ http.Handler = (*handler)(nil)
56

Callers 5

DiscoveryHandlerFunction · 0.92
NewNotificationV1Function · 0.92
NewIndexerV1Function · 0.92
NewMatcherV1Function · 0.92
setupHandlerFunction · 0.70

Calls

no outgoing calls

Tested by 1

setupHandlerFunction · 0.56