mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-20 23:07:33 +00:00
21 lines
377 B
Go
21 lines
377 B
Go
package service
|
|
|
|
import "context"
|
|
|
|
type serviceKey struct{}
|
|
|
|
var key *serviceKey = (*serviceKey)(nil)
|
|
|
|
func WithService(parent context.Context, serviceName string) context.Context {
|
|
return context.WithValue(parent, key, serviceName)
|
|
}
|
|
|
|
func FromContext(ctx context.Context) string {
|
|
value := ctx.Value(key)
|
|
if name, ok := value.(string); ok {
|
|
return name
|
|
}
|
|
|
|
return ""
|
|
}
|