mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-10 21:52:01 +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)
|
Init(...Option)
|
||||||
// Options returns the current options
|
// Options returns the current options
|
||||||
Options() Options
|
Options() Options
|
||||||
|
// Register the handler
|
||||||
|
Handle(v interface{}) error
|
||||||
// Client is used to call services
|
// Client is used to call services
|
||||||
Client() client.Client
|
Client() client.Client
|
||||||
// Server is for handling requests and events
|
// Server is for handling requests and events
|
||||||
|
@@ -126,6 +126,12 @@ func (s *service) Stop() error {
|
|||||||
return err
|
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) {
|
func (s *service) Run() (err error) {
|
||||||
logger := s.opts.Logger
|
logger := s.opts.Logger
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user