swarm: modify context key (#17925)
* swarm: modify context key * gofmt sctx.go
This commit is contained in:
committed by
Viktor Trón
parent
126dfde6c9
commit
baee850471
@ -2,19 +2,17 @@ package sctx
|
||||
|
||||
import "context"
|
||||
|
||||
type ContextKey int
|
||||
|
||||
const (
|
||||
HTTPRequestIDKey ContextKey = iota
|
||||
requestHostKey
|
||||
type (
|
||||
HTTPRequestIDKey struct{}
|
||||
requestHostKey struct{}
|
||||
)
|
||||
|
||||
func SetHost(ctx context.Context, domain string) context.Context {
|
||||
return context.WithValue(ctx, requestHostKey, domain)
|
||||
return context.WithValue(ctx, requestHostKey{}, domain)
|
||||
}
|
||||
|
||||
func GetHost(ctx context.Context) string {
|
||||
v, ok := ctx.Value(requestHostKey).(string)
|
||||
v, ok := ctx.Value(requestHostKey{}).(string)
|
||||
if ok {
|
||||
return v
|
||||
}
|
||||
|
Reference in New Issue
Block a user