Skip to content

Commit da09755

Browse files
committed
fix: configure H2C from the Go std lib
1 parent d0630de commit da09755

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

pkg/server/server.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ import (
3737
"github.com/prometheus/client_golang/prometheus/collectors"
3838
"github.com/prometheus/client_golang/prometheus/promhttp"
3939
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
40-
"golang.org/x/net/http2"
41-
"golang.org/x/net/http2/h2c"
4240
"google.golang.org/grpc"
4341
"google.golang.org/grpc/codes"
4442
"google.golang.org/grpc/credentials/insecure"
@@ -150,22 +148,21 @@ func (s *Server) ListenAndServe(
150148
return fmt.Errorf("failed to walk ui filesystem: %w", err)
151149
}
152150

153-
h2s := &http2.Server{}
151+
p := new(http.Protocols)
152+
p.SetHTTP1(true)
153+
p.SetUnencryptedHTTP2(true)
154154
s.Server = &http.Server{
155155
Addr: addr,
156-
Handler: h2c.NewHandler(grpcHandlerFunc(
156+
Handler: grpcHandlerFunc(
157157
srv,
158158
fallbackNotFound(internalMux, uiHandler),
159159
allowedCORSOrigins,
160-
), h2s),
160+
),
161+
Protocols: p,
161162
ReadTimeout: readTimeout,
162163
WriteTimeout: writeTimeout,
163164
}
164165

165-
if err := http2.ConfigureServer(s.Server, h2s); err != nil {
166-
return fmt.Errorf("failed to configure HTTP/2 server: %w", err)
167-
}
168-
169166
met.InitializeMetrics(srv)
170167
s.reg.MustRegister(met)
171168

0 commit comments

Comments
 (0)