weiro/models/ctx.go
Leon Mika e77cac2fd5 Started working on the frontend
- Added the new post frontend
- Hooked up publishing of posts to the site publisher
- Added an site exporter as a publishing target
2026-02-21 10:22:10 +11:00

28 lines
585 B
Go

package models
import "context"
type userKeyType struct{}
type siteKeyType struct{}
var userKey = userKeyType{}
var siteKey = userKeyType{}
func WithUser(ctx context.Context, user User) context.Context {
return context.WithValue(ctx, userKey, user)
}
func GetUser(ctx context.Context) (User, bool) {
user, ok := ctx.Value(userKey).(User)
return user, ok
}
func WithSite(ctx context.Context, site Site) context.Context {
return context.WithValue(ctx, siteKey, site)
}
func GetSite(ctx context.Context) (Site, bool) {
site, ok := ctx.Value(siteKey).(Site)
return site, ok
}