diff options
author | Elad <theman@elad.im> | 2018-08-07 17:56:55 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-07 17:56:55 +0800 |
commit | 93fe16b0a5162a158ee74d9f398107f31074a8f1 (patch) | |
tree | 5838389dd827c05e380c85a4e0dae04189bf07c6 /swarm/api/http/sctx.go | |
parent | 64a4e89504b683074077b54518633b76c59ab507 (diff) | |
download | dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar.gz dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar.bz2 dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar.lz dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar.xz dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.tar.zst dexon-93fe16b0a5162a158ee74d9f398107f31074a8f1.zip |
swarm/api/http: refactored http package (#17309)
Diffstat (limited to 'swarm/api/http/sctx.go')
-rw-r--r-- | swarm/api/http/sctx.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/swarm/api/http/sctx.go b/swarm/api/http/sctx.go new file mode 100644 index 000000000..431e11735 --- /dev/null +++ b/swarm/api/http/sctx.go @@ -0,0 +1,38 @@ +package http + +import ( + "context" + + "github.com/ethereum/go-ethereum/swarm/api" + "github.com/ethereum/go-ethereum/swarm/sctx" +) + +type contextKey int + +const ( + uriKey contextKey = iota +) + +func GetRUID(ctx context.Context) string { + v, ok := ctx.Value(sctx.HTTPRequestIDKey).(string) + if ok { + return v + } + return "xxxxxxxx" +} + +func SetRUID(ctx context.Context, ruid string) context.Context { + return context.WithValue(ctx, sctx.HTTPRequestIDKey, ruid) +} + +func GetURI(ctx context.Context) *api.URI { + v, ok := ctx.Value(uriKey).(*api.URI) + if ok { + return v + } + return nil +} + +func SetURI(ctx context.Context, uri *api.URI) context.Context { + return context.WithValue(ctx, uriKey, uri) +} |