Browse Source

graceful: opportunistic keep-alives for Serve

Carl Jackson 11 years ago
parent
commit
46b46e00f4
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      graceful/server.go

+ 6
- 1
graceful/server.go View File

@ -96,8 +96,13 @@ func ListenAndServeTLS(addr, certfile, keyfile string, handler http.Handler) err
return server.ListenAndServeTLS(certfile, keyfile)
}
// Serve behaves exactly like the net/http function of the same name.
// Serve mostly behaves like the net/http function of the same name, except that
// if the passed listener is a net.TCPListener, TCP keep-alives are enabled on
// accepted connections.
func Serve(l net.Listener, handler http.Handler) error {
if tl, ok := l.(*net.TCPListener); ok {
l = tcpKeepAliveListener{tl}
}
server := &Server{Handler: handler}
return server.Serve(l)
}

Loading…
Cancel
Save