micro/router/service/options.go

23 lines
430 B
Go
Raw Normal View History

package service
import (
"context"
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/router"
)
type clientKey struct{}
// Client to call router service
func Client(c client.Client) router.Option {
return func(o *router.Options) {
if o.Context == nil {
o.Context = context.WithValue(context.Background(), clientKey{}, c)
return
}
o.Context = context.WithValue(o.Context, clientKey{}, c)
}
}