github.com/shyftnetwork/go-empyrean@v1.8.3-0.20191127201940-fbfca9338f04/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  }