mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
25 lines
474 B
Go
25 lines
474 B
Go
package etcd
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/micro/go-micro/registry"
|
|
)
|
|
|
|
type authKey struct{}
|
|
|
|
type authCreds struct {
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
// Auth allows you to specify username/password
|
|
func Auth(username, password string) registry.Option {
|
|
return func(o *registry.Options) {
|
|
if o.Context == nil {
|
|
o.Context = context.Background()
|
|
}
|
|
o.Context = context.WithValue(o.Context, authKey{}, &authCreds{Username: username, Password: password})
|
|
}
|
|
}
|