blob: 3a30dbb0b62ae264190fafc81b9d1a2c8dbf20ca (
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
|
package tvm
import "context"
type (
serviceTicketContextKey struct{}
userTicketContextKey struct{}
)
var (
stKey serviceTicketContextKey
utKey userTicketContextKey
)
// WithServiceTicket returns copy of the ctx with service ticket attached to it.
func WithServiceTicket(ctx context.Context, t *CheckedServiceTicket) context.Context {
return context.WithValue(ctx, &stKey, t)
}
// WithUserTicket returns copy of the ctx with user ticket attached to it.
func WithUserTicket(ctx context.Context, t *CheckedUserTicket) context.Context {
return context.WithValue(ctx, &utKey, t)
}
func ContextServiceTicket(ctx context.Context) (t *CheckedServiceTicket) {
t, _ = ctx.Value(&stKey).(*CheckedServiceTicket)
return
}
func ContextUserTicket(ctx context.Context) (t *CheckedUserTicket) {
t, _ = ctx.Value(&utKey).(*CheckedUserTicket)
return
}
|