context.go 359 B

12345678910111213
  1. package interrupt
  2. import "context"
  3. type contextKeyIsExternalConnection struct{}
  4. func ContextWithIsExternalConnection(ctx context.Context) context.Context {
  5. return context.WithValue(ctx, contextKeyIsExternalConnection{}, true)
  6. }
  7. func IsExternalConnectionFromContext(ctx context.Context) bool {
  8. return ctx.Value(contextKeyIsExternalConnection{}) != nil
  9. }