From 27b0251b5b8c1097d53b20a67569bb9bb6ff8bff Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Mon, 19 Sep 2022 17:17:12 +0300 Subject: [PATCH] home: imp docs --- internal/home/web.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/home/web.go b/internal/home/web.go index 5bd1fe30..2052df55 100644 --- a/internal/home/web.go +++ b/internal/home/web.go @@ -169,15 +169,15 @@ func (web *Web) Start() { printHTTPAddresses(schemeHTTP) errs := make(chan error, 2) - // h2s adds support for plain h2c - h2s := &http2.Server{} + // Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies. + hdlr := h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody), &http2.Server{}) + // Create a new instance, because the Web is not usable after Shutdown. hostStr := web.conf.BindHost.String() - // we need to have new instance, because after Shutdown() the Server is not usable web.httpServer = &http.Server{ ErrorLog: log.StdLog("web: plain", log.DEBUG), Addr: netutil.JoinHostPort(hostStr, web.conf.BindPort), - Handler: h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody), h2s), + Handler: hdlr, ReadTimeout: web.conf.ReadTimeout, ReadHeaderTimeout: web.conf.ReadHeaderTimeout, WriteTimeout: web.conf.WriteTimeout, @@ -207,13 +207,16 @@ func (web *Web) startBetaServer(hostStr string) { return } - // h2s adds support for plain h2c - h2s := &http2.Server{} + // Use an h2c handler to support unencrypted HTTP/2, e.g. for proxies. + hdlr := h2c.NewHandler( + withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta), + &http2.Server{}, + ) web.httpServerBeta = &http.Server{ ErrorLog: log.StdLog("web: plain: beta", log.DEBUG), Addr: netutil.JoinHostPort(hostStr, web.conf.BetaBindPort), - Handler: h2c.NewHandler(withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta), h2s), + Handler: hdlr, ReadTimeout: web.conf.ReadTimeout, ReadHeaderTimeout: web.conf.ReadHeaderTimeout, WriteTimeout: web.conf.WriteTimeout,