From a244abab161336891582163a3ad2dd4d152d493a Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Sat, 10 Jan 2026 11:35:17 -0500 Subject: [PATCH] Add timeouts for HTTP server --- cmd/screenjournal/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/screenjournal/main.go b/cmd/screenjournal/main.go index 61a4015f..1e5efe84 100644 --- a/cmd/screenjournal/main.go +++ b/cmd/screenjournal/main.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "strconv" + "time" gorilla "github.com/mtlynch/gorilla-handlers" @@ -78,7 +79,14 @@ func main() { } log.Printf("listening on %s", port) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil)) + server := &http.Server{ + Addr: fmt.Sprintf(":%s", port), + ReadHeaderTimeout: 5 * time.Second, + ReadTimeout: 15 * time.Second, + WriteTimeout: 15 * time.Second, + IdleTimeout: 60 * time.Second, + } + log.Fatal(server.ListenAndServe()) } func requireEnv(key string) string {