zitadel/internal/api/service/service.go

21 lines
379 B
Go
Raw Normal View History

2020-11-06 21:09:19 +00:00
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 ""
}