package htmx import "context" type contextKey string const htmxContextKey contextKey = "htmx" type Context struct { IsHTMX bool IsPartial bool IsBoosted bool Target string Trigger string TriggerID string CurrentURL string } func WithContext(ctx context.Context, hc *Context) context.Context { return context.WithValue(ctx, htmxContextKey, hc) } func FromContext(ctx context.Context) *Context { if hc, ok := ctx.Value(htmxContextKey).(*Context); ok { return hc } return &Context{} } func IsHTMXRequest(ctx context.Context) bool { return FromContext(ctx).IsHTMX } func IsPartialRequest(ctx context.Context) bool { return FromContext(ctx).IsPartial }