2018-08-07 04:56:55 -05:00
|
|
|
package sctx
|
|
|
|
|
2018-08-15 10:41:52 -05:00
|
|
|
import "context"
|
|
|
|
|
2018-11-06 02:54:19 -06:00
|
|
|
type (
|
|
|
|
HTTPRequestIDKey struct{}
|
|
|
|
requestHostKey struct{}
|
2018-08-07 04:56:55 -05:00
|
|
|
)
|
2018-08-15 10:41:52 -05:00
|
|
|
|
|
|
|
func SetHost(ctx context.Context, domain string) context.Context {
|
2018-11-06 02:54:19 -06:00
|
|
|
return context.WithValue(ctx, requestHostKey{}, domain)
|
2018-08-15 10:41:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetHost(ctx context.Context) string {
|
2018-11-06 02:54:19 -06:00
|
|
|
v, ok := ctx.Value(requestHostKey{}).(string)
|
2018-08-15 10:41:52 -05:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|