INNER CODE UNIT · Go
MustGetAccount
arp242/goatcounter · context.go:120
func MustGetAccount(ctx context.Context) *Site {
a, err := GetAccount(ctx)
if err != nil {
panic(err)
}
return a
}
// WithUser adds the site to the context.
func WithUser(ctx context.Context, u *User) context.Context {
return context.WithValue(ctx, ctxkey.User, u)
}
// GetUser gets the currently logged in user.
func GetUser(ctx context.Context) *User {
u, _ := ctx.Value(ctxkey.User).(*User)
if u == nil || u.ID == 0 {
s := GetSite(ctx)