Serve acts just like http.Serve. It is a blocking call until the server is closed, and an error is returned if any underlying Serve call fails.
(srv *http.Server)
| 2713 | // Serve acts just like http.Serve. It is a blocking call until the server |
| 2714 | // is closed, and an error is returned if any underlying Serve call fails. |
| 2715 | func (s *HTTPServers) Serve(srv *http.Server) error { |
| 2716 | eg := errgroup.Group{} |
| 2717 | if s.HTTPListener != nil { |
| 2718 | eg.Go(func() error { |
| 2719 | defer s.Close() // close all listeners on error |
| 2720 | return srv.Serve(s.HTTPListener) |
| 2721 | }) |
| 2722 | } |
| 2723 | if s.TLSListener != nil { |
| 2724 | eg.Go(func() error { |
| 2725 | defer s.Close() // close all listeners on error |
| 2726 | return srv.Serve(s.TLSListener) |
| 2727 | }) |
| 2728 | } |
| 2729 | return eg.Wait() |
| 2730 | } |
| 2731 | |
| 2732 | func (s *HTTPServers) Close() { |
| 2733 | if s.HTTPListener != nil { |