diff --git a/main.go b/main.go index 34ed110..a148d17 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "io/fs" "log" "net/http" + "time" ) var version = "development" @@ -25,7 +26,15 @@ func main() { log.Printf("app built from revision '%s'\n", version) log.Print("Listening on :1314...") - err = http.ListenAndServe(":1314", nil) + // https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ + srv := http.Server{ + ReadTimeout: 15 * time.Second, + WriteTimeout: 15 * time.Second, + Addr: ":1314", + Handler: nil, + } + + err = srv.ListenAndServe() if err != nil { log.Fatal(err) }