mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-12 12:27:09 +02:00
14 lines
314 B
Go
14 lines
314 B
Go
package apiauth
|
|
|
|
import "context"
|
|
|
|
type principalKey struct{}
|
|
|
|
func WithPrincipal(ctx context.Context, p *Principal) context.Context {
|
|
return context.WithValue(ctx, principalKey{}, p)
|
|
}
|
|
|
|
func PrincipalFrom(ctx context.Context) (*Principal, bool) {
|
|
p, ok := ctx.Value(principalKey{}).(*Principal)
|
|
return p, ok
|
|
}
|