http.go 619 B

1234567891011121314151617181920212223
  1. package etcdmain
  2. import (
  3. "io/ioutil"
  4. "log"
  5. "net"
  6. "net/http"
  7. "time"
  8. )
  9. // serveHTTP accepts incoming HTTP connections on the listener l,
  10. // creating a new service goroutine for each. The service goroutines
  11. // read requests and then call handler to reply to them.
  12. func serveHTTP(l net.Listener, handler http.Handler, readTimeout time.Duration) error {
  13. logger := log.New(ioutil.Discard, "etcdhttp", 0)
  14. // TODO: add debug flag; enable logging when debug flag is set
  15. srv := &http.Server{
  16. Handler: handler,
  17. ReadTimeout: readTimeout,
  18. ErrorLog: logger, // do not log user error
  19. }
  20. return srv.Serve(l)
  21. }