fixup cors path handler
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		
							
								
								
									
										13
									
								
								http.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								http.go
									
									
									
									
									
								
							| @@ -233,9 +233,9 @@ func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) s | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if h.registerCORS { | 		if h.registerCORS { | ||||||
| 			h.opts.Logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s /%s", hn, hn) | 			h.opts.Logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s", md["Path"]) | ||||||
| 			if err := hdlr.handlers.Insert([]string{http.MethodOptions}, "/"+hn, pth); err != nil { | 			if err := hdlr.handlers.Insert([]string{http.MethodOptions}, md["Path"], pth); err != nil { | ||||||
| 				h.opts.Logger.Errorf(h.opts.Context, "cant add rpc handler for http.MethodOptions %s /%s", hn, hn) | 				h.opts.Logger.Errorf(h.opts.Context, "cant add handler for %s %s", md["Method"], md["Path"]) | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -244,6 +244,13 @@ func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) s | |||||||
| 			if err := hdlr.handlers.Insert([]string{http.MethodPost}, "/"+hn, pth); err != nil { | 			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.Errorf(h.opts.Context, "cant add rpc handler for http.MethodPost %s /%s", hn, hn) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | 			if h.registerCORS { | ||||||
|  | 				h.opts.Logger.Infof(h.opts.Context, "register cors handler for http.MethodOptions %s /%s", hn, hn) | ||||||
|  | 				if err := hdlr.handlers.Insert([]string{http.MethodOptions}, "/"+hn, pth); err != nil { | ||||||
|  | 					h.opts.Logger.Errorf(h.opts.Context, "cant add rpc handler for http.MethodOptions %s /%s", hn, hn) | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user