blob: bed2b1145821a2bbe2daa8958d8b62c81b840e40 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package sctx
import "context"
type ContextKey int
const (
HTTPRequestIDKey ContextKey = iota
requestHostKey
)
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 ""
}
|