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