dispatcher.go 408 B

123456789101112131415161718192021222324
  1. // +build !confonly
  2. package dispatcher
  3. import "context"
  4. //go:generate errorgen
  5. type key int
  6. const (
  7. sniffing key = iota
  8. )
  9. func ContextWithSniffingResult(ctx context.Context, r SniffResult) context.Context {
  10. return context.WithValue(ctx, sniffing, r)
  11. }
  12. func SniffingResultFromContext(ctx context.Context) SniffResult {
  13. if c, ok := ctx.Value(sniffing).(SniffResult); ok {
  14. return c
  15. }
  16. return nil
  17. }