dispatcher.go 387 B

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