1
0
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:
asim
2025-04-23 12:13:23 +01:00
parent 517b2b0855
commit 156a968253
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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