Documentation
¶
Index ¶
- func AcceptLayer(c *http.Context, value any)
- func Context(c *http.Context) map[string]any
- func DismissLayer(c *http.Context, value any)
- func EmitEvent(c *http.Context, eventType string, props map[string]any)
- func EvictCache(c *http.Context, pattern string)
- func ExpireCache(c *http.Context, pattern string)
- func FailContext(c *http.Context) map[string]any
- func FailMode(c *http.Context) string
- func FailTarget(c *http.Context) string
- func IsUnpoly(c *http.Context) bool
- func IsValidating(c *http.Context) bool
- func Mode(c *http.Context) string
- func RenderNothing(c *http.Context)
- func ServerProtocol() router.Middleware
- func SetLocation(c *http.Context, url string)
- func SetMethod(c *http.Context, method string)
- func SetTarget(c *http.Context, selector string)
- func SetTitle(c *http.Context, title string)
- func Target(c *http.Context) string
- func Validate(c *http.Context) string
- func ValidateNames(c *http.Context) []string
- func Version(c *http.Context) string
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptLayer ¶
AcceptLayer closes the targeted overlay and accepts it with the given value (X-Up-Accept-Layer, serialized as JSON). The value becomes the overlay's acceptance value.
func Context ¶
Context returns the targeted layer's context object from X-Up-Context (parsed from JSON), or nil.
func DismissLayer ¶
DismissLayer closes the targeted overlay and dismisses it with the given value (X-Up-Dismiss-Layer, serialized as JSON).
func EmitEvent ¶
EmitEvent sends a client-side event via X-Up-Events. The event is serialized as JSON. Call multiple times to emit multiple events.
func EvictCache ¶
EvictCache tells Unpoly to evict (delete) cached responses matching the given URL pattern (X-Up-Evict-Cache). Use "*" to evict all.
func ExpireCache ¶
ExpireCache tells Unpoly to expire cached responses matching the given URL pattern (X-Up-Expire-Cache). Use "*" to expire all. Expired entries are re-validated on next use.
func FailContext ¶
FailContext returns the layer context for a failed update (X-Up-Fail-Context).
func FailTarget ¶
FailTarget returns the CSS selector for a failed update (X-Up-Fail-Target).
func IsValidating ¶
IsValidating returns true if Unpoly is validating form fields.
func Mode ¶
Mode returns the targeted layer's mode (X-Up-Mode): "root", "modal", "popup", "drawer", or "cover".
func RenderNothing ¶
RenderNothing tells Unpoly to skip rendering by setting X-Up-Target: :none. The response body can be empty.
func ServerProtocol ¶
func ServerProtocol() router.Middleware
ServerProtocol returns middleware that implements the Unpoly server protocol. For every request that carries an X-Up-Version header it:
- Echoes X-Up-Location with the current request URL
- Echoes X-Up-Method with the current HTTP method
- Adds Vary: X-Up-Target, X-Up-Version for cache partitioning
Non-Unpoly requests pass through untouched.
func SetLocation ¶
SetLocation overrides the browser location shown after a fragment update (X-Up-Location). Useful after redirects or rewrites.
func SetMethod ¶
SetMethod overrides the HTTP method echoed back to Unpoly (X-Up-Method). Useful after method-changing redirects.
func SetTarget ¶
SetTarget overrides the CSS selector that Unpoly will update (X-Up-Target response header). Useful when the server wants to render a different fragment than what was requested.
func SetTitle ¶
SetTitle changes the document title after a fragment update (X-Up-Title). The value is JSON-encoded as Unpoly expects. Set to "false" to prevent Unpoly from changing the title.
func Target ¶
Target returns the CSS selector Unpoly is targeting (X-Up-Target), or an empty string for non-Unpoly / full-page requests.
func Validate ¶
Validate returns the names of form fields being validated (X-Up-Validate), or an empty string if this is not a validation request.
func ValidateNames ¶
ValidateNames returns the individual field names being validated as a slice.
Types ¶
type Plugin ¶
type Plugin struct {
nimbus.BasePlugin
}
Plugin integrates the Unpoly server protocol with Nimbus.
func (*Plugin) DefaultConfig ¶
DefaultConfig returns the default configuration for the Unpoly plugin.
func (*Plugin) Middleware ¶
func (p *Plugin) Middleware() map[string]router.Middleware
Middleware returns the named middleware provided by this plugin.
"unpoly" — the server protocol middleware. Register it as server middleware in start/kernel.go so every Unpoly request gets the required response headers.