From 542d4cec0062491106ddb4910ad7c1ab90027479 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 18 Mar 2024 16:38:18 +0300 Subject: [PATCH] improve cors Signed-off-by: Vasiliy Tolstov --- http.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http.go b/http.go index 1ce6523..1c970e0 100644 --- a/http.go +++ b/http.go @@ -232,7 +232,10 @@ func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) s if h.registerCORS { logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s", md["Path"]) methods = append(methods, http.MethodOptions) + } else { + logger.Infof(h.opts.Context, "not register cors handler for http.MethodOptions %s", md["Path"]) } + if err := hdlr.handlers.Insert(methods, md["Path"], pth); err != nil { logger.Errorf(h.opts.Context, "cant add handler for %v %s", methods, md["Path"]) } @@ -243,6 +246,8 @@ func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) s if h.registerCORS { logger.Infof(h.opts.Context, "register cors handler for %v %s", methods, "/"+hn) methods = append(methods, http.MethodOptions) + } else { + logger.Infof(h.opts.Context, "not register cors handler for %v %s", methods, "/"+hn) } if err := hdlr.handlers.Insert(methods, "/"+hn, pth); err != nil {