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