mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-04 21:42:57 +02:00
directly support handler in the service interface
This commit is contained in:
2
micro.go
2
micro.go
@ -20,6 +20,8 @@ type Service interface {
|
||||
Init(...Option)
|
||||
// Options returns the current options
|
||||
Options() Options
|
||||
// Register the handler
|
||||
Handle(v interface{}) error
|
||||
// Client is used to call services
|
||||
Client() client.Client
|
||||
// Server is for handling requests and events
|
||||
|
@ -126,6 +126,12 @@ func (s *service) Stop() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *service) Handle(v interface{}) error {
|
||||
return s.opts.Server.Handle(
|
||||
s.opts.Server.NewHandler(h),
|
||||
)
|
||||
}
|
||||
|
||||
func (s *service) Run() (err error) {
|
||||
logger := s.opts.Logger
|
||||
|
||||
|
Reference in New Issue
Block a user