micro/router/service/options.go
ben-toogood a2550820d3
router: add to service options; add dns and static implementations (#1733)
* config/cmd: add router to service options

* router/service: use micro client
2020-06-24 11:46:51 +01:00

23 lines
430 B
Go

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)
}
}