From 2d5fb587a03d6419f65dde23cbaeff19ededc7a5 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 24 Jan 2022 20:29:52 +0300 Subject: [PATCH] ignore net.ErrClosed Signed-off-by: Vasiliy Tolstov --- http.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http.go b/http.go index a7cf7e0..86a723c 100644 --- a/http.go +++ b/http.go @@ -4,6 +4,7 @@ package http // import "go.unistack.org/micro-server-http/v3" import ( "context" "crypto/tls" + "errors" "fmt" "net" "net/http" @@ -496,13 +497,13 @@ func (h *httpServer) Start() error { if srvFunc != nil { go func() { - if cerr := srvFunc(ts); cerr != nil && !strings.Contains(cerr.Error(), "use of closed network connection") { + if cerr := srvFunc(ts); cerr != nil && !errors.Is(cerr, net.ErrClosed) { h.opts.Logger.Error(h.opts.Context, cerr) } }() } else { go func() { - if cerr := http.Serve(ts, fn); cerr != nil && !strings.Contains(cerr.Error(), "use of closed network connection") { + if cerr := http.Serve(ts, fn); cerr != nil && !errors.Is(cerr, net.ErrClosed) { h.opts.Logger.Error(h.opts.Context, cerr) } }()