policies implemented

This commit is contained in:
adlerhurst
2020-11-06 22:09:19 +01:00
parent f7f810caa5
commit 57fc3ddd16
22 changed files with 667 additions and 87 deletions

View File

@@ -0,0 +1,20 @@
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 ""
}