2018-08-07 12:56:55 +03:00
|
|
|
package sctx
|
|
|
|
|
2018-08-15 18:41:52 +03:00
|
|
|
import "context"
|
|
|
|
|
2018-08-07 12:56:55 +03:00
|
|
|
type ContextKey int
|
|
|
|
|
|
|
|
const (
|
|
|
|
HTTPRequestIDKey ContextKey = iota
|
2018-08-15 18:41:52 +03:00
|
|
|
requestHostKey
|
2018-08-07 12:56:55 +03:00
|
|
|
)
|
2018-08-15 18:41:52 +03:00
|
|
|
|
|
|
|
func SetHost(ctx context.Context, domain string) context.Context {
|
|
|
|
return context.WithValue(ctx, requestHostKey, domain)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetHost(ctx context.Context) string {
|
|
|
|
v, ok := ctx.Value(requestHostKey).(string)
|
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|