this repo has no description
1package request
2
3import (
4 "context"
5
6 "github.com/bluesky-social/indigo/atproto/identity"
7 "tangled.org/core/appview/models"
8)
9
10type (
11 ctxKeyOwner struct{}
12 ctxKeyRepo struct{}
13 ctxKeyIssue struct{}
14)
15
16func WithOwner(ctx context.Context, owner *identity.Identity) context.Context {
17 return context.WithValue(ctx, ctxKeyOwner{}, owner)
18}
19
20func OwnerFromContext(ctx context.Context) (*identity.Identity, bool) {
21 owner, ok := ctx.Value(ctxKeyOwner{}).(*identity.Identity)
22 return owner, ok
23}
24
25func WithRepo(ctx context.Context, repo *models.Repo) context.Context {
26 return context.WithValue(ctx, ctxKeyRepo{}, repo)
27}
28
29func RepoFromContext(ctx context.Context) (*models.Repo, bool) {
30 repo, ok := ctx.Value(ctxKeyRepo{}).(*models.Repo)
31 return repo, ok
32}
33
34func WithIssue(ctx context.Context, issue *models.Issue) context.Context {
35 return context.WithValue(ctx, ctxKeyIssue{}, issue)
36}
37
38func IssueFromContext(ctx context.Context) (*models.Issue, bool) {
39 issue, ok := ctx.Value(ctxKeyIssue{}).(*models.Issue)
40 return issue, ok
41}