(ln net.Listener, h http.Handler, cfg config.TimeoutCfg)
| 194 | } |
| 195 | |
| 196 | func newServer(ln net.Listener, h http.Handler, cfg config.TimeoutCfg) *http.Server { |
| 197 | // nolint:gosec // We already configured ReadTimeout, so no need to set ReadHeaderTimeout as well. |
| 198 | return &http.Server{ |
| 199 | TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), |
| 200 | Handler: h, |
| 201 | ReadTimeout: time.Duration(cfg.ReadTimeout), |
| 202 | WriteTimeout: time.Duration(cfg.WriteTimeout), |
| 203 | IdleTimeout: time.Duration(cfg.IdleTimeout), |
| 204 | // Suppress error logging from the server, since chproxy |
| 205 | // must handle all these errors in the code. |
| 206 | ErrorLog: log.NilLogger, |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | func listenAndServe(ln net.Listener, h http.Handler, cfg config.TimeoutCfg) error { |
| 211 | s := newServer(ln, h, cfg) |
no outgoing calls