aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/http/sctx.go
blob: b8dafab0b79d3f2890cd92d5058cd929375cb857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package http

import (
    "context"

    "github.com/ethereum/go-ethereum/swarm/api"
    "github.com/ethereum/go-ethereum/swarm/sctx"
)

type uriKey struct{}

func GetRUID(ctx context.Context) string {
    v, ok := ctx.Value(sctx.HTTPRequestIDKey{}).(string)
    if ok {
        return v
    }
    return "xxxxxxxx"
}

func SetRUID(ctx context.Context, ruid string) context.Context {
    return context.WithValue(ctx, sctx.HTTPRequestIDKey{}, ruid)
}

func GetURI(ctx context.Context) *api.URI {
    v, ok := ctx.Value(uriKey{}).(*api.URI)
    if ok {
        return v
    }
    return nil
}

func SetURI(ctx context.Context, uri *api.URI) context.Context {
    return context.WithValue(ctx, uriKey{}, uri)
}