From 1d5142d619664bb3bc7e335560306c1ce0b805a8 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Thu, 7 Mar 2024 18:12:49 +0300 Subject: [PATCH 1/6] removed using http.Serve and add using *http.Server + Shutdown --- .gitignore | 24 ++++++++++++++++++++++++ http.go | 48 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e16696 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +bin + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +# General +.DS_Store +.idea +.vscode \ No newline at end of file diff --git a/http.go b/http.go index 97da7b2..fa4bdc8 100644 --- a/http.go +++ b/http.go @@ -408,7 +408,7 @@ func (h *Server) Start() error { h.Unlock() var handler http.Handler - var srvFunc func(net.Listener) error + //var srvFunc func(net.Listener) error // nolint: nestif if h.opts.Context != nil { @@ -451,6 +451,7 @@ func (h *Server) Start() error { fn := handler + var hs *http.Server if h.opts.Context != nil { if mwf, ok := h.opts.Context.Value(middlewareKey{}).([]func(http.Handler) http.Handler); ok && len(mwf) > 0 { // wrap the handler func @@ -458,25 +459,37 @@ func (h *Server) Start() error { fn = mwf[i-1](fn) } } - if hs, ok := h.opts.Context.Value(serverKey{}).(*http.Server); ok && hs != nil { + var ok bool + if hs, ok = h.opts.Context.Value(serverKey{}).(*http.Server); ok && hs != nil { hs.Handler = fn - srvFunc = hs.Serve + //srvFunc = hs.Serve + } else { + hs = &http.Server{Handler: fn} } } - if srvFunc != nil { - go func() { - 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 && !errors.Is(cerr, net.ErrClosed) { - h.opts.Logger.Error(h.opts.Context, cerr) - } - }() - } + go func() { + if cerr := hs.Serve(ts); cerr != nil && !errors.Is(cerr, net.ErrClosed) { + h.opts.Logger.Error(h.opts.Context, cerr) + } + }() + + /* + if srvFunc != nil { + go func() { + 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 && !errors.Is(cerr, net.ErrClosed) { + h.opts.Logger.Error(h.opts.Context, cerr) + } + }() + } + + */ go func() { t := new(time.Ticker) @@ -536,6 +549,9 @@ func (h *Server) Start() error { config.Logger.Errorf(config.Context, "Server deregister error: %s", err) } + // err ignore and empty cotnext + hs.Shutdown(context.Background()) + ch <- ts.Close() }() -- 2.45.2 From 41d7d145ceaa1e3d0216cbcdf5e8fdc358374ac9 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Thu, 7 Mar 2024 18:16:02 +0300 Subject: [PATCH 2/6] removed Listener.Stop --- http.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/http.go b/http.go index fa4bdc8..a988406 100644 --- a/http.go +++ b/http.go @@ -549,10 +549,9 @@ func (h *Server) Start() error { config.Logger.Errorf(config.Context, "Server deregister error: %s", err) } - // err ignore and empty cotnext - hs.Shutdown(context.Background()) - - ch <- ts.Close() + // empty context + // TODO ts.Listener is sopped? + ch <- hs.Shutdown(context.Background()) }() return nil -- 2.45.2 From 49608197d0574f6271f42c9aa9d15b9ba08fbab4 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Thu, 7 Mar 2024 18:17:07 +0300 Subject: [PATCH 3/6] removed comments code --- http.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/http.go b/http.go index a988406..08c91a2 100644 --- a/http.go +++ b/http.go @@ -408,7 +408,6 @@ func (h *Server) Start() error { h.Unlock() var handler http.Handler - //var srvFunc func(net.Listener) error // nolint: nestif if h.opts.Context != nil { @@ -462,7 +461,6 @@ func (h *Server) Start() error { var ok bool if hs, ok = h.opts.Context.Value(serverKey{}).(*http.Server); ok && hs != nil { hs.Handler = fn - //srvFunc = hs.Serve } else { hs = &http.Server{Handler: fn} } @@ -474,23 +472,6 @@ func (h *Server) Start() error { } }() - /* - if srvFunc != nil { - go func() { - 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 && !errors.Is(cerr, net.ErrClosed) { - h.opts.Logger.Error(h.opts.Context, cerr) - } - }() - } - - */ - go func() { t := new(time.Ticker) -- 2.45.2 From ea8c9dd22e675292e03b37554cb400d6bcfb4020 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Fri, 8 Mar 2024 17:58:18 +0300 Subject: [PATCH 4/6] update micro version and add gracefulTimeout && update log msg --- go.mod | 6 +++--- go.sum | 12 ++++++------ http.go | 55 +++++++++++++++++++++++++++++-------------------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index 70c7bfc..1873033 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,9 @@ go 1.19 require ( go.unistack.org/micro-codec-yaml/v4 v4.0.0 go.unistack.org/micro-proto/v4 v4.0.1 - go.unistack.org/micro/v4 v4.0.6 + go.unistack.org/micro/v4 v4.0.17 go.unistack.org/protoc-gen-go-micro/v4 v4.0.7 - golang.org/x/net v0.12.0 + golang.org/x/net v0.15.0 ) require ( @@ -15,7 +15,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic v0.6.9 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/sys v0.12.0 // indirect golang.org/x/tools v0.11.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 389bdaf..f6e712c 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ go.unistack.org/micro-codec-yaml/v4 v4.0.0 h1:DK/+fA69gmnvYmGHe3kqVR0pukS8ank5lP go.unistack.org/micro-codec-yaml/v4 v4.0.0/go.mod h1:UG4ouILbUfgNL7nvp7CpmD2IIzO8bQHjzDIahOvIAgM= go.unistack.org/micro-proto/v4 v4.0.1 h1:2RKHgtCOOcAFgKsnngGK5bqM/6MWXOjVCdw03dbuoF8= go.unistack.org/micro-proto/v4 v4.0.1/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec= -go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk= -go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk= +go.unistack.org/micro/v4 v4.0.17 h1:mF7uM+J4ILdG+1fcwzKYCwDlxhdbF/e1WnGzKKLnIXc= +go.unistack.org/micro/v4 v4.0.17/go.mod h1:ZDgU9931vm2l7X6RN/6UuwRIVp24GRdmQ7dKmegArk4= go.unistack.org/protoc-gen-go-micro/v4 v4.0.7 h1:c3CeBvjWV9MBrGGPaQCcHZrnuLY9sVJHv7vACI/dvuM= go.unistack.org/protoc-gen-go-micro/v4 v4.0.7/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -94,8 +94,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -111,8 +111,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/http.go b/http.go index 08c91a2..fff7238 100644 --- a/http.go +++ b/http.go @@ -198,16 +198,16 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht } if method.Name == "" && h.opts.Logger.V(logger.ErrorLevel) { - h.opts.Logger.Errorf(h.opts.Context, "nil method for %s", mname) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil method for %s", mname)) continue } mtype, err := prepareEndpoint(method) if err != nil && h.opts.Logger.V(logger.ErrorLevel) { - h.opts.Logger.Errorf(h.opts.Context, "%v", err) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("%v", err)) continue } else if mtype == nil { - h.opts.Logger.Errorf(h.opts.Context, "nil mtype for %s", mname) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil mtype for %s", mname)) continue } @@ -218,13 +218,13 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht hdlr.name = name if err := hdlr.handlers.Insert([]string{md["Method"]}, md["Path"], pth); err != nil { - h.opts.Logger.Errorf(h.opts.Context, "cant add handler for %s %s", md["Method"], md["Path"]) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add handler for %s %s", md["Method"], md["Path"])) } if h.registerRPC { - h.opts.Logger.Infof(h.opts.Context, "register rpc handler for http.MethodPost %s /%s", hn, hn) + h.opts.Logger.Info(h.opts.Context, fmt.Sprintf("register rpc handler for http.MethodPost %s /%s", hn, hn)) if err := hdlr.handlers.Insert([]string{http.MethodPost}, "/"+hn, pth); err != nil { - h.opts.Logger.Errorf(h.opts.Context, "cant add rpc handler for http.MethodPost %s /%s", hn, hn) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add rpc handler for http.MethodPost %s /%s", hn, hn)) } } } @@ -248,16 +248,16 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht } if method.Name == "" && h.opts.Logger.V(logger.ErrorLevel) { - h.opts.Logger.Errorf(h.opts.Context, "nil method for %s", mname) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil method for %s", mname)) continue } mtype, err := prepareEndpoint(method) if err != nil && h.opts.Logger.V(logger.ErrorLevel) { - h.opts.Logger.Errorf(h.opts.Context, "%v", err) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("%v", err)) continue } else if mtype == nil { - h.opts.Logger.Errorf(h.opts.Context, "nil mtype for %s", mname) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil mtype for %s", mname)) continue } @@ -268,13 +268,13 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht hdlr.name = name if err := hdlr.handlers.Insert([]string{md.Method}, md.Path, pth); err != nil { - h.opts.Logger.Errorf(h.opts.Context, "cant add handler for %s %s", md.Method, md.Path) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add handler for %s %s", md.Method, md.Path)) } if h.registerRPC { - h.opts.Logger.Infof(h.opts.Context, "register rpc handler for http.MethodPost %s /%s", hn, hn) + h.opts.Logger.Info(h.opts.Context, fmt.Sprintf("register rpc handler for http.MethodPost %s /%s", hn, hn)) if err := hdlr.handlers.Insert([]string{http.MethodPost}, "/"+hn, pth); err != nil { - h.opts.Logger.Errorf(h.opts.Context, "cant add rpc handler for http.MethodPost %s /%s", hn, hn) + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add rpc handler for http.MethodPost %s /%s", hn, hn)) } } } @@ -317,7 +317,7 @@ func (h *Server) Register() error { if !registered { if config.Logger.V(logger.InfoLevel) { - config.Logger.Infof(config.Context, "Register [%s] Registering node: %s", config.Register.String(), service.Nodes[0].ID) + config.Logger.Info(config.Context, fmt.Sprintf("Register [%s] Registering node: %s", config.Register.String(), service.Nodes[0].ID)) } } @@ -350,7 +350,7 @@ func (h *Server) Deregister() error { } if config.Logger.V(logger.InfoLevel) { - config.Logger.Infof(config.Context, "Deregistering node: %s", service.Nodes[0].ID) + config.Logger.Info(config.Context, fmt.Sprintf("Deregistering node: %s", service.Nodes[0].ID)) } if err := server.DefaultDeregisterFunc(service, config); err != nil { @@ -400,7 +400,7 @@ func (h *Server) Start() error { } if config.Logger.V(logger.InfoLevel) { - config.Logger.Infof(config.Context, "Listening on %s", ts.Addr().String()) + config.Logger.Info(config.Context, fmt.Sprintf("Listening on %s", ts.Addr().String())) } h.Lock() @@ -440,7 +440,7 @@ func (h *Server) Start() error { if err := config.RegisterCheck(h.opts.Context); err != nil { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Errorf(config.Context, "Server %s-%s register check error: %s", config.Name, config.ID, err) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s", config.Name, config.ID, err)) } } else { if err = h.Register(); err != nil { @@ -468,7 +468,7 @@ func (h *Server) Start() error { go func() { if cerr := hs.Serve(ts); cerr != nil && !errors.Is(cerr, net.ErrClosed) { - h.opts.Logger.Error(h.opts.Context, cerr) + h.opts.Logger.Error(h.opts.Context, fmt.Sprint(cerr)) } }() @@ -496,28 +496,28 @@ func (h *Server) Start() error { // nolint: nestif if rerr != nil && registered { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Errorf(config.Context, "Server %s-%s register check error: %s, deregister it", config.Name, config.ID, rerr) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s, deregister it", config.Name, config.ID, rerr)) } // deregister self in case of error if err := h.Deregister(); err != nil { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Errorf(config.Context, "Server %s-%s deregister error: %s", config.Name, config.ID, err) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s deregister error: %s", config.Name, config.ID, err)) } } } else if rerr != nil && !registered { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Errorf(config.Context, "Server %s-%s register check error: %s", config.Name, config.ID, rerr) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s", config.Name, config.ID, rerr)) } continue } if err := h.Register(); err != nil { if config.Logger.V(logger.ErrorLevel) { - config.Logger.Errorf(config.Context, "Server %s-%s register error: %s", config.Name, config.ID, err) + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register error: %s", config.Name, config.ID, err)) } } if err := h.Register(); err != nil { - config.Logger.Errorf(config.Context, "Server register error: %s", err) + config.Logger.Error(config.Context, fmt.Sprintf("Server register error: %s", err)) } // wait for exit case ch = <-h.exit: @@ -527,12 +527,15 @@ func (h *Server) Start() error { // deregister if err := h.Deregister(); err != nil { - config.Logger.Errorf(config.Context, "Server deregister error: %s", err) + config.Logger.Error(config.Context, fmt.Sprintf("Server deregister error: %s", err)) } - // empty context - // TODO ts.Listener is sopped? - ch <- hs.Shutdown(context.Background()) + ctx, cancel := context.WithTimeout(context.Background(), h.opts.GracefulTimeout) + defer cancel() + + if err := hs.Shutdown(ctx); err != nil { + ch <- hs.Close() + } }() return nil -- 2.45.2 From 143258736906b6a379f3263b9fdbeba8a197eda1 Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Fri, 8 Mar 2024 18:00:02 +0300 Subject: [PATCH 5/6] sent err to channel --- http.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/http.go b/http.go index fff7238..902c148 100644 --- a/http.go +++ b/http.go @@ -533,9 +533,12 @@ func (h *Server) Start() error { ctx, cancel := context.WithTimeout(context.Background(), h.opts.GracefulTimeout) defer cancel() - if err := hs.Shutdown(ctx); err != nil { - ch <- hs.Close() + err := hs.Shutdown(ctx) + if err != nil { + err = hs.Close() } + + ch <- err }() return nil -- 2.45.2 From 2e8462a0f19289a6a9fc82a4e8a9d5fa4c41852c Mon Sep 17 00:00:00 2001 From: Evstigneev Denis Date: Fri, 8 Mar 2024 18:03:50 +0300 Subject: [PATCH 6/6] fix logmessages --- handler.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/handler.go b/handler.go index 078dccd..f3faf7f 100644 --- a/handler.go +++ b/handler.go @@ -22,7 +22,7 @@ var ( DefaultErrorHandler = func(ctx context.Context, s interface{}, w http.ResponseWriter, r *http.Request, err error, status int) { w.WriteHeader(status) if _, cerr := w.Write([]byte(err.Error())); cerr != nil { - logger.DefaultLogger.Errorf(ctx, "write failed: %v", cerr) + logger.DefaultLogger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) } } DefaultContentType = "application/json" @@ -318,7 +318,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) } if err != nil && handler.sopts.Logger.V(logger.ErrorLevel) { - handler.sopts.Logger.Errorf(handler.sopts.Context, "handler err: %v", err) + handler.sopts.Logger.Error(handler.sopts.Context, fmt.Sprintf("handler err: %v", err)) return } @@ -328,7 +328,7 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) w.WriteHeader(scode) if _, cerr := w.Write(buf); cerr != nil { - handler.sopts.Logger.Errorf(ctx, "write failed: %v", cerr) + handler.sopts.Logger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) } }, nil } @@ -581,7 +581,7 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if err != nil && handler.sopts.Logger.V(logger.ErrorLevel) { - handler.sopts.Logger.Errorf(handler.sopts.Context, "handler err: %v", err) + handler.sopts.Logger.Error(handler.sopts.Context, fmt.Sprintf("handler err: %v", err)) return } @@ -591,6 +591,6 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(scode) if _, cerr := w.Write(buf); cerr != nil { - handler.sopts.Logger.Errorf(ctx, "write failed: %v", cerr) + handler.sopts.Logger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) } } -- 2.45.2