micro v4 fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
259e1d275e
commit
966bc31eb2
22
http.go
22
http.go
@ -122,12 +122,22 @@ func (h *Server) Init(opts ...options.Option) error {
|
||||
|
||||
func (h *Server) Handle(handler interface{}, opts ...options.Option) error {
|
||||
options := server.NewHandleOptions(opts...)
|
||||
var endpointMetadata []EndpointMetadata
|
||||
|
||||
if v, ok := options.Context.Value(handlerEndpointsKey{}).([]EndpointMetadata); ok {
|
||||
endpointMetadata = v
|
||||
}
|
||||
|
||||
// passed unknown handler
|
||||
hdlr, ok := handler.(*httpHandler)
|
||||
if !ok {
|
||||
h.Lock()
|
||||
h.hd = handler
|
||||
if h.handlers == nil {
|
||||
h.handlers = make(map[string]interface{})
|
||||
}
|
||||
for _, v := range endpointMetadata {
|
||||
h.handlers[v.Name] = h.newHTTPHandler(handler, opts...)
|
||||
}
|
||||
h.Unlock()
|
||||
return nil
|
||||
}
|
||||
@ -140,16 +150,6 @@ func (h *Server) Handle(handler interface{}, opts ...options.Option) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// passed micro compat handler
|
||||
h.Lock()
|
||||
if h.handlers == nil {
|
||||
h.handlers = make(map[string]interface{})
|
||||
}
|
||||
for k := range options.Metadata {
|
||||
h.handlers[k] = handler
|
||||
}
|
||||
h.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user