http.go 550 B

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