diff options
author | Elad <theman@elad.im> | 2019-04-30 12:10:57 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2019-05-10 18:26:45 +0800 |
commit | 12240baf61e251a80e3759dd22ca5847dcb8d807 (patch) | |
tree | 34226b31335b8db2903a0d915366cf6cf4d44f9a /swarm/sctx | |
parent | f8eb8fe64c1fa4ba85fe3e6af1f8bcdf6c936b04 (diff) | |
download | go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar.gz go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar.bz2 go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar.lz go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar.xz go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.tar.zst go-tangerine-12240baf61e251a80e3759dd22ca5847dcb8d807.zip |
swarm/chunk: add tags data type
* swarm/chunk: add tags backend to chunk package
Diffstat (limited to 'swarm/sctx')
-rw-r--r-- | swarm/sctx/sctx.go | 17 |
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 +} |