github.com/susy-go/susy-graviton@v0.0.0-20190614130430-36cddae42305/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  }