aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/sctx
diff options
context:
space:
mode:
authorElad <theman@elad.im>2018-08-15 23:41:52 +0800
committerBalint Gabor <balint.g@gmail.com>2018-08-15 23:41:52 +0800
commite8752f4e9f9be3d2932cd4835a5d72d17ac2338b (patch)
tree73f1514fc0134f2f5ef4b467f1076548b8a18bc3 /swarm/sctx
parent040aa2bb101e5e602308b24812bfbf2451b21174 (diff)
downloadgo-tangerine-e8752f4e9f9be3d2932cd4835a5d72d17ac2338b.tar.gz
go-tangerine-e8752f4e9f9be3d2932cd4835a5d72d17ac2338b.tar.zst
go-tangerine-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.go15
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 ""
+}