diff options
author | Elad <theman@elad.im> | 2018-08-15 23:41:52 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-08-15 23:41:52 +0800 |
commit | e8752f4e9f9be3d2932cd4835a5d72d17ac2338b (patch) | |
tree | 73f1514fc0134f2f5ef4b467f1076548b8a18bc3 /swarm/sctx | |
parent | 040aa2bb101e5e602308b24812bfbf2451b21174 (diff) | |
download | dexon-e8752f4e9f9be3d2932cd4835a5d72d17ac2338b.tar.gz dexon-e8752f4e9f9be3d2932cd4835a5d72d17ac2338b.tar.zst dexon-e8752f4e9f9be3d2932cd4835a5d72d17ac2338b.zip |
cmd/swarm, swarm: added access control functionality (#17404)
Co-authored-by: Janos Guljas <janos@resenje.org>
Co-authored-by: Anton Evangelatov <anton.evangelatov@gmail.com>
Co-authored-by: Balint Gabor <balint.g@gmail.com>
Diffstat (limited to 'swarm/sctx')
-rw-r--r-- | swarm/sctx/sctx.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/swarm/sctx/sctx.go b/swarm/sctx/sctx.go index 8619f6e19..bed2b1145 100644 --- a/swarm/sctx/sctx.go +++ b/swarm/sctx/sctx.go @@ -1,7 +1,22 @@ package sctx +import "context" + type ContextKey int const ( HTTPRequestIDKey ContextKey = iota + requestHostKey ) + +func SetHost(ctx context.Context, domain string) context.Context { + return context.WithValue(ctx, requestHostKey, domain) +} + +func GetHost(ctx context.Context) string { + v, ok := ctx.Value(requestHostKey).(string) + if ok { + return v + } + return "" +} |