about summary refs log tree commit diff stats
path: root/internal/server/server.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-25 18:10:30 +0200
committerAlan Pearce2024-05-25 18:10:30 +0200
commit16b433791b619f4144110e4429d98684bf5e98eb (patch)
tree022d1e6ab97e71620c8daae0053c4e057497bb99 /internal/server/server.go
parentb65fdaad764314991f502f3702b904a11f0fe6e7 (diff)
downloadsearchix-16b433791b619f4144110e4429d98684bf5e98eb.tar.lz
searchix-16b433791b619f4144110e4429d98684bf5e98eb.tar.zst
searchix-16b433791b619f4144110e4429d98684bf5e98eb.zip
feat: support cleartext HTTP/2 (i.e. from a reverse proxy)
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 262e9a7..38200bb 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -11,6 +11,8 @@ import (
 	"time"
 
 	"github.com/pkg/errors"
+	"golang.org/x/net/http2"
+	"golang.org/x/net/http2/h2c"
 )
 
 type Server struct {
@@ -28,7 +30,12 @@ func New(conf *config.Config, index *index.ReadIndex, liveReload bool) (*Server,
 	return &Server{
 		cfg: conf,
 		server: &http.Server{
-			Handler:           mux,
+			Handler: http.MaxBytesHandler(
+				h2c.NewHandler(mux, &http2.Server{
+					IdleTimeout: 5 * time.Minute,
+				}),
+				1024*1024,
+			),
 			ReadHeaderTimeout: 20 * time.Second,
 		},
 	}, nil