diff --git a/server/rpc_server.go b/server/rpc_server.go index 6cc1846b..08cd0787 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -112,6 +112,12 @@ func (s *rpcServer) Init(opts ...Option) error { for _, opt := range opts { opt(&s.opts) } + // update internal server + s.rpc = &server{ + name: s.opts.Name, + serviceMap: s.rpc.serviceMap, + hdlrWrappers: s.opts.HdlrWrappers, + } s.Unlock() return nil } @@ -121,12 +127,15 @@ func (s *rpcServer) NewHandler(h interface{}, opts ...HandlerOption) Handler { } func (s *rpcServer) Handle(h Handler) error { + s.Lock() + defer s.Unlock() + if err := s.rpc.register(h.Handler()); err != nil { return err } - s.Lock() + s.handlers[h.Name()] = h - s.Unlock() + return nil } diff --git a/server/rpcplus_server.go b/server/rpcplus_server.go index d5fc9d93..7c281241 100644 --- a/server/rpcplus_server.go +++ b/server/rpcplus_server.go @@ -234,7 +234,7 @@ func (s *service) call(ctx context.Context, server *server, sending *sync.Mutex, var returnValues []reflect.Value r := &rpcRequest{ - service: s.name, + service: server.name, contentType: ct, method: req.ServiceMethod, }