zitadel/internal/api/service/service.go

21 lines
377 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)
2020-11-26 08:19:14 +00:00
func WithService(parent context.Context, serviceName string) context.Context {
return context.WithValue(parent, key, serviceName)
2020-11-06 21:09:19 +00:00
}
func FromContext(ctx context.Context) string {
value := ctx.Value(key)
if name, ok := value.(string); ok {
return name
}
return ""
}