add timeouts to net/http serve

This commit is contained in:
2022-01-19 13:18:21 +01:00
parent 11aa1a3a49
commit 1928a9df64

16
main.go
View File

@@ -1070,7 +1070,13 @@ func main() {
}
sockets = append(sockets, sL)
go func() {
_ = http.Serve(sL, cors(proxyRouter))
srv := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: cors(proxyRouter),
}
_ = srv.Serve(sL)
}()
} else {
log.Infof("Listening on %s:%d", l.Host, l.Port)
@@ -1079,7 +1085,13 @@ func main() {
log.Fatalf("Failure listing on %s:%d: %v", l.Host, l.Port, err)
}
go func() {
err = http.Serve(tL, cors(proxyRouter))
srv := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: cors(proxyRouter),
}
err = srv.Serve(tL)
if err != nil {
log.Fatalf("Failure serving on %s:%d: %v", l.Host, l.Port, err)
}