all repos — website @ b65aa0a6d8c735763cfb237db2b158b892abf77c

My website

server: support h2c
Alan Pearce alan@alanpearce.eu
Fri, 24 May 2024 20:13:25 +0200
commit

b65aa0a6d8c735763cfb237db2b158b892abf77c

parent

f1269cec2d85f21823f1d79eda5d6e29fa2a0cfa

2 files changed, 13 insertions(+), 4 deletions(-)

jump to
M fly.tomlfly.toml
@@ -29,6 +29,8 @@ [http_service.concurrency]     type = "requests"
     hard_limit = 20000
     soft_limit = 15000
+[http_service.http_options]
+  h2_backend = true
 [http_service.http_options.response]
   pristine = true
 [[http_service.checks]]
M internal/server/server.gointernal/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
 }