mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Inject Namespace into Context
This commit is contained in:
@ -133,3 +133,11 @@ func ContextWithAccount(ctx context.Context, account *Account) (context.Context,
|
||||
// generate a new context with the MetadataKey set
|
||||
return metadata.Set(ctx, MetadataKey, string(bytes)), nil
|
||||
}
|
||||
|
||||
// NamespaceFromContext gets the namespace from the context
|
||||
func NamespaceFromContext(ctx context.Context) string {
|
||||
if ns, ok := metadata.Get(ctx, NamespaceKey); ok {
|
||||
return ns
|
||||
}
|
||||
return DefaultNamespace
|
||||
}
|
||||
|
Reference in New Issue
Block a user