safeweb: add a ListenAndServe method to the Server type (#13498)

Updates #13497

Change-Id: I398e9fa58ad0b9dc799ea280c9c7a32150150ee4
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
bradfitz/tool_go
M. J. Fromberger 3 days ago committed by GitHub
parent 951884b077
commit 5f89c93274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -301,6 +301,19 @@ func (s *Server) Serve(ln net.Listener) error {
return s.h.Serve(ln)
}
// ListenAndServe listens on the TCP network address addr and then calls Serve
// to handle requests on incoming connections. If addr == "", ":http" is used.
func (s *Server) ListenAndServe(addr string) error {
if addr == "" {
addr = ":http"
}
lst, err := net.Listen("tcp", addr)
if err != nil {
return err
}
return s.Serve(lst)
}
// Close closes all client connections and stops accepting new ones.
func (s *Server) Close() error {
return s.h.Close()

Loading…
Cancel
Save