github.com/alexdevranger/node-1.8.27@v0.0.0-20221128213301-aa5841e41d2d/swarm/sctx/sctx.go (about) 1 package sctx 2 3 import "context" 4 5 type ( 6 HTTPRequestIDKey struct{} 7 requestHostKey struct{} 8 ) 9 10 func SetHost(ctx context.Context, domain string) context.Context { 11 return context.WithValue(ctx, requestHostKey{}, domain) 12 } 13 14 func GetHost(ctx context.Context) string { 15 v, ok := ctx.Value(requestHostKey{}).(string) 16 if ok { 17 return v 18 } 19 return "" 20 }