improve cors
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0ecd1da0dc
commit
542d4cec00
5
http.go
5
http.go
@ -232,7 +232,10 @@ func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) s
|
|||||||
if h.registerCORS {
|
if h.registerCORS {
|
||||||
logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s", md["Path"])
|
logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s", md["Path"])
|
||||||
methods = append(methods, http.MethodOptions)
|
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 {
|
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"])
|
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 {
|
if h.registerCORS {
|
||||||
logger.Infof(h.opts.Context, "register cors handler for %v %s", methods, "/"+hn)
|
logger.Infof(h.opts.Context, "register cors handler for %v %s", methods, "/"+hn)
|
||||||
methods = append(methods, http.MethodOptions)
|
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 {
|
if err := hdlr.handlers.Insert(methods, "/"+hn, pth); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user