system_dialer_context.go 392 B

123456789101112131415161718
  1. package internet
  2. import "context"
  3. type systemDialer int
  4. const systemDialerKey systemDialer = 0
  5. func ContextWithLookupDomain(ctx context.Context, domain string) context.Context {
  6. return context.WithValue(ctx, systemDialerKey, domain)
  7. }
  8. func LookupDomainFromContext(ctx context.Context) string {
  9. if domain, ok := ctx.Value(systemDialerKey).(string); ok {
  10. return domain
  11. }
  12. return ""
  13. }