2018-08-07 12:56:55 +03:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/swarm/api"
|
|
|
|
"github.com/ethereum/go-ethereum/swarm/sctx"
|
|
|
|
)
|
|
|
|
|
2018-11-06 11:54:19 +03:00
|
|
|
type uriKey struct{}
|
2018-08-07 12:56:55 +03:00
|
|
|
|
|
|
|
func GetRUID(ctx context.Context) string {
|
2018-11-06 11:54:19 +03:00
|
|
|
v, ok := ctx.Value(sctx.HTTPRequestIDKey{}).(string)
|
2018-08-07 12:56:55 +03:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return "xxxxxxxx"
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetRUID(ctx context.Context, ruid string) context.Context {
|
2018-11-06 11:54:19 +03:00
|
|
|
return context.WithValue(ctx, sctx.HTTPRequestIDKey{}, ruid)
|
2018-08-07 12:56:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetURI(ctx context.Context) *api.URI {
|
2018-11-06 11:54:19 +03:00
|
|
|
v, ok := ctx.Value(uriKey{}).(*api.URI)
|
2018-08-07 12:56:55 +03:00
|
|
|
if ok {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetURI(ctx context.Context, uri *api.URI) context.Context {
|
2018-11-06 11:54:19 +03:00
|
|
|
return context.WithValue(ctx, uriKey{}, uri)
|
2018-08-07 12:56:55 +03:00
|
|
|
}
|