aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api
diff options
context:
space:
mode:
authorKimMachineGun <geon0250@gmail.com>2018-11-06 16:54:19 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2018-11-06 16:54:19 +0800
commitbaee850471603d7fbf37eed0074c9de01df92ee7 (patch)
treecb53c5391d910589a80138c1757a2cc6d27feb04 /swarm/api
parent126dfde6c9de1f8122bb3991453d2429b47542f8 (diff)
downloadgo-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/api')
-rw-r--r--swarm/api/http/sctx.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/swarm/api/http/sctx.go b/swarm/api/http/sctx.go
index 431e11735..b8dafab0b 100644
--- a/swarm/api/http/sctx.go
+++ b/swarm/api/http/sctx.go
@@ -7,14 +7,10 @@ import (
"github.com/ethereum/go-ethereum/swarm/sctx"
)
-type contextKey int
-
-const (
- uriKey contextKey = iota
-)
+type uriKey struct{}
func GetRUID(ctx context.Context) string {
- v, ok := ctx.Value(sctx.HTTPRequestIDKey).(string)
+ v, ok := ctx.Value(sctx.HTTPRequestIDKey{}).(string)
if ok {
return v
}
@@ -22,11 +18,11 @@ func GetRUID(ctx context.Context) string {
}
func SetRUID(ctx context.Context, ruid string) context.Context {
- return context.WithValue(ctx, sctx.HTTPRequestIDKey, ruid)
+ return context.WithValue(ctx, sctx.HTTPRequestIDKey{}, ruid)
}
func GetURI(ctx context.Context) *api.URI {
- v, ok := ctx.Value(uriKey).(*api.URI)
+ v, ok := ctx.Value(uriKey{}).(*api.URI)
if ok {
return v
}
@@ -34,5 +30,5 @@ func GetURI(ctx context.Context) *api.URI {
}
func SetURI(ctx context.Context, uri *api.URI) context.Context {
- return context.WithValue(ctx, uriKey, uri)
+ return context.WithValue(ctx, uriKey{}, uri)
}