Explorar o código

http service timeout

ls %!s(int64=4) %!d(string=hai) anos
pai
achega
f8908e8e08
Modificáronse 1 ficheiros con 11 adicións e 7 borrados
  1. 11 7
      serve.go

+ 11 - 7
serve.go

@@ -12,17 +12,21 @@ import (
 )
 
 var (
-	readTimeout  = 30 * time.Second
-	writeTimeout = 30 * time.Second
+	readTimeout       = 30 * time.Second
+	readHeaderTimeout = 30 * time.Second
+	writeTimeout      = 30 * time.Second
+	idleTimeout       = 30 * time.Second
 )
 
 func newServe(addr string, router http.Handler) *http.Server {
 	return &http.Server{
-		Addr:           addr,
-		Handler:        router,
-		ReadTimeout:    readTimeout,
-		WriteTimeout:   writeTimeout,
-		MaxHeaderBytes: MB,
+		Addr:              addr,
+		Handler:           router,
+		ReadTimeout:       readTimeout,
+		ReadHeaderTimeout: readHeaderTimeout,
+		WriteTimeout:      writeTimeout,
+		IdleTimeout:       idleTimeout,
+		MaxHeaderBytes:    MB,
 	}
 }