github.com/FUSIONFoundation/efsn@v3.6.2-0.20200916075423-dbb5dd5d2cc7+incompatible/swarm/api/http/sctx.go (about) 1 package http 2 3 import ( 4 "context" 5 6 "github.com/FusionFoundation/efsn/swarm/api" 7 "github.com/FusionFoundation/efsn/swarm/sctx" 8 ) 9 10 type contextKey int 11 12 const ( 13 uriKey contextKey = iota 14 ) 15 16 func GetRUID(ctx context.Context) string { 17 v, ok := ctx.Value(sctx.HTTPRequestIDKey).(string) 18 if ok { 19 return v 20 } 21 return "xxxxxxxx" 22 } 23 24 func SetRUID(ctx context.Context, ruid string) context.Context { 25 return context.WithValue(ctx, sctx.HTTPRequestIDKey, ruid) 26 } 27 28 func GetURI(ctx context.Context) *api.URI { 29 v, ok := ctx.Value(uriKey).(*api.URI) 30 if ok { 31 return v 32 } 33 return nil 34 } 35 36 func SetURI(ctx context.Context, uri *api.URI) context.Context { 37 return context.WithValue(ctx, uriKey, uri) 38 }