mirror of
https://github.com/go-micro/go-micro.git
synced 2025-05-19 21:23:04 +02:00
30 lines
590 B
Go
30 lines
590 B
Go
|
package mucp
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/micro/go-micro/v2/config/source"
|
||
|
)
|
||
|
|
||
|
type serviceNameKey struct{}
|
||
|
type pathKey struct{}
|
||
|
|
||
|
func WithServiceName(a string) source.Option {
|
||
|
return func(o *source.Options) {
|
||
|
if o.Context == nil {
|
||
|
o.Context = context.Background()
|
||
|
}
|
||
|
o.Context = context.WithValue(o.Context, serviceNameKey{}, a)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// WithPath sets the key prefix to use
|
||
|
func WithPath(p string) source.Option {
|
||
|
return func(o *source.Options) {
|
||
|
if o.Context == nil {
|
||
|
o.Context = context.Background()
|
||
|
}
|
||
|
o.Context = context.WithValue(o.Context, pathKey{}, p)
|
||
|
}
|
||
|
}
|