File: context.go

package info (click to toggle)
relic 7.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,108 kB
  • sloc: sh: 230; makefile: 10
file content (16 lines) | stat: -rw-r--r-- 293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package token

import "context"

type ctxKey int

var ctxKeyID ctxKey = 1

func WithKeyID(ctx context.Context, keyID []byte) context.Context {
	return context.WithValue(ctx, ctxKeyID, keyID)
}

func KeyID(ctx context.Context) []byte {
	keyID, _ := ctx.Value(ctxKeyID).([]byte)
	return keyID
}