feat: Add HTTP2 for unencrypted HTTP (v3) (#4248)

This commit is contained in:
Milos Gajdos
2024-01-18 20:51:58 +07:00
committed by GitHub
22 changed files with 397 additions and 124 deletions

View File

@@ -20,6 +20,8 @@ import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"golang.org/x/crypto/acme"
"golang.org/x/crypto/acme/autocert"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"github.com/distribution/distribution/v3/configuration"
"github.com/distribution/distribution/v3/health"
@@ -158,6 +160,9 @@ func NewRegistry(ctx context.Context, config *configuration.Configuration) (*Reg
if err != nil {
return nil, fmt.Errorf("error during open telemetry initialization: %v", err)
}
if config.HTTP.H2C.Enabled {
handler = h2c.NewHandler(handler, &http2.Server{})
}
handler = otelHandler(handler)
server := &http.Server{