diff options
author | KimMachineGun <geon0250@gmail.com> | 2018-11-06 16:54:19 +0800 |
---|---|---|
committer | Viktor TrĂ³n <viktor.tron@gmail.com> | 2018-11-06 16:54:19 +0800 |
commit | baee850471603d7fbf37eed0074c9de01df92ee7 (patch) | |
tree | cb53c5391d910589a80138c1757a2cc6d27feb04 /swarm/sctx | |
parent | 126dfde6c9de1f8122bb3991453d2429b47542f8 (diff) | |
download | go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar.gz go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar.bz2 go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar.lz go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar.xz go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.tar.zst go-tangerine-baee850471603d7fbf37eed0074c9de01df92ee7.zip |
swarm: modify context key (#17925)
* swarm: modify context key
* gofmt sctx.go
Diffstat (limited to 'swarm/sctx')
-rw-r--r-- | swarm/sctx/sctx.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/swarm/sctx/sctx.go b/swarm/sctx/sctx.go index bed2b1145..fb7d35b00 100644 --- a/swarm/sctx/sctx.go +++ b/swarm/sctx/sctx.go @@ -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 } |