2018-09-05 15:36:14 +00:00
|
|
|
package sctx
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
2018-11-21 15:30:00 +00:00
|
|
|
type (
|
|
|
|
HTTPRequestIDKey struct{}
|
|
|
|
requestHostKey struct{}
|
2018-09-05 15:36:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func SetHost(ctx context.Context, domain string) context.Context {
|
2018-11-21 15:30:00 +00:00
|
|
|
return context.WithValue(ctx, requestHostKey{}, domain)
|
2018-09-05 15:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetHost(ctx context.Context) string {
|
2018-11-21 15:30:00 +00:00
|
|
|
v, ok := ctx.Value(requestHostKey{}).(string)
|
2018-09-05 15:36:14 +00:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|