Authenticate on service start

This commit is contained in:
Ben Toogood
2020-05-13 13:13:11 +01:00
parent 346e034d0a
commit 54951740bf
4 changed files with 99 additions and 57 deletions

View File

@@ -0,0 +1,21 @@
package service
import (
"context"
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/registry"
)
type clientKey struct{}
// WithClient sets the RPC client
func WithClient(c client.Client) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, clientKey{}, c)
}
}