aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/sctx
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-05-10 19:09:01 +0800
committerGitHub <noreply@github.com>2019-05-10 19:09:01 +0800
commit494f5d448a1685d5de4cb1524b863cd1fc9a13b0 (patch)
tree4db9d1afe4910c888f3488cd93e8537501d88314 /swarm/sctx
parentc94d582aa781b26412ba7d570f6707d193303a02 (diff)
parent9b1543c282f39d452f611eeee0307bdf828e8bc2 (diff)
downloadgo-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.gz
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.bz2
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.lz
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.xz
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.tar.zst
go-tangerine-494f5d448a1685d5de4cb1524b863cd1fc9a13b0.zip
Merge pull request #19550 from ethersphere/swarm-rather-stable
swarm v0.4-rc1
Diffstat (limited to 'swarm/sctx')
-rw-r--r--swarm/sctx/sctx.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/swarm/sctx/sctx.go b/swarm/sctx/sctx.go
index fb7d35b00..adc8c7dab 100644
--- a/swarm/sctx/sctx.go
+++ b/swarm/sctx/sctx.go
@@ -5,12 +5,15 @@ import "context"
type (
HTTPRequestIDKey struct{}
requestHostKey struct{}
+ tagKey struct{}
)
+// SetHost sets the http request host in the context
func SetHost(ctx context.Context, domain string) context.Context {
return context.WithValue(ctx, requestHostKey{}, domain)
}
+// GetHost gets the request host from the context
func GetHost(ctx context.Context) string {
v, ok := ctx.Value(requestHostKey{}).(string)
if ok {
@@ -18,3 +21,17 @@ func GetHost(ctx context.Context) string {
}
return ""
}
+
+// SetTag sets the tag unique identifier in the context
+func SetTag(ctx context.Context, tagId uint32) context.Context {
+ return context.WithValue(ctx, tagKey{}, tagId)
+}
+
+// GetTag gets the tag unique identifier from the context
+func GetTag(ctx context.Context) uint32 {
+ v, ok := ctx.Value(tagKey{}).(uint32)
+ if ok {
+ return v
+ }
+ return 0
+}