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