server: support h2c
Alan Pearce alan@alanpearce.eu
Fri, 24 May 2024 20:13:25 +0200
2 files changed, 13 insertions(+), 4 deletions(-)
M internal/server/server.go → internal/server/server.go
@@ -16,6 +16,8 @@ "github.com/getsentry/sentry-go" sentryhttp "github.com/getsentry/sentry-go/http" "github.com/pkg/errors" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" ) var config *cfg.Config @@ -105,11 +107,16 @@ return &Server{ &http.Server{ Addr: listenAddress, ReadHeaderTimeout: 1 * time.Minute, - Handler: sentryHandler.Handle( - serverHeaderHandler( - wrapHandlerWithLogging(top), + Handler: http.MaxBytesHandler(h2c.NewHandler( + sentryHandler.Handle( + serverHeaderHandler( + wrapHandlerWithLogging(top), + ), ), - ), + &http2.Server{ + IdleTimeout: 15 * time.Minute, + }, + ), 0), }, }, nil }