Skip to content

Commit 156a968

Browse files
committed
directly support handler in the service interface
1 parent 517b2b0 commit 156a968

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

micro.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type Service interface {
2020
Init(...Option)
2121
// Options returns the current options
2222
Options() Options
23+
// Register the handler
24+
Handle(v interface{}) error
2325
// Client is used to call services
2426
Client() client.Client
2527
// Server is for handling requests and events

service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ func (s *service) Stop() error {
126126
return err
127127
}
128128

129+
func (s *service) Handle(v interface{}) error {
130+
return s.opts.Server.Handle(
131+
s.opts.Server.NewHandler(h),
132+
)
133+
}
134+
129135
func (s *service) Run() (err error) {
130136
logger := s.opts.Logger
131137

0 commit comments

Comments
 (0)