2018-09-05 15:36:14 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/swarm/api"
|
|
|
|
"github.com/ethereum/go-ethereum/swarm/sctx"
|
|
|
|
)
|
|
|
|
|
2018-11-21 15:30:00 +00:00
|
|
|
type uriKey struct{}
|
2018-09-05 15:36:14 +00:00
|
|
|
|
|
|
|
func GetRUID(ctx context.Context) string {
|
2018-11-21 15:30:00 +00:00
|
|
|
v, ok := ctx.Value(sctx.HTTPRequestIDKey{}).(string)
|
2018-09-05 15:36:14 +00:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return "xxxxxxxx"
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetRUID(ctx context.Context, ruid string) context.Context {
|
2018-11-21 15:30:00 +00:00
|
|
|
return context.WithValue(ctx, sctx.HTTPRequestIDKey{}, ruid)
|
2018-09-05 15:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetURI(ctx context.Context) *api.URI {
|
2018-11-21 15:30:00 +00:00
|
|
|
v, ok := ctx.Value(uriKey{}).(*api.URI)
|
2018-09-05 15:36:14 +00:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetURI(ctx context.Context, uri *api.URI) context.Context {
|
2018-11-21 15:30:00 +00:00
|
|
|
return context.WithValue(ctx, uriKey{}, uri)
|
2018-09-05 15:36:14 +00:00
|
|
|
}
|