From a21ebe5af225d18b53220cdf13d376d663c44722 Mon Sep 17 00:00:00 2001 From: Adora Laura Kalb Date: Thu, 18 Apr 2024 11:10:56 +0200 Subject: [PATCH] configure timeouts for http.Server (#1) --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c109601..ac10d7f 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "net/http" "net/netip" "os" + "time" "github.com/alecthomas/kingpin/v2" "github.com/go-kit/log" @@ -146,7 +147,12 @@ func main() { http.Handle("/", landingPage) } - srv := &http.Server{} + srv := &http.Server{ + ReadHeaderTimeout: 15 * time.Second, + ReadTimeout: 15 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, + } if err := web.ListenAndServe(srv, toolkitFlags, logger); err != nil { level.Error(logger).Log("msg", "Error starting HTTP server", "err", err) os.Exit(1) -- 2.39.5