INNER CODE UNIT · Go

MustGetSite

arp242/goatcounter · context.go:96

func MustGetSite(ctx context.Context) *Site {
	s, ok := ctx.Value(ctxkey.Site).(*Site)
	if !ok {
		panic("MustGetSite: no site on context")
	}
	return s
}

// GetAccount gets this site's "account site" on which the users, etc. are
// stored.
func GetAccount(ctx context.Context) (*Site, error) {
	s := MustGetSite(ctx)
	if s.Parent == nil {
		return s, nil
	}

	var account Site
	err := account.ByID(ctx, *s.Parent)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…