Documentation ¶
Overview ¶
htmx package provides helpers to read htmx headers from http.Request and add htmx headers to http.ResponseWriter.
It embeds a filesystem with the latest build of htmx, minified. The filesystem is exposed via FS() for convenience, although it might move to somewhere else or removed altogether in the future without prior notice.
Index ¶
- Constants
- func FS() fs.FS
- func IsRequest(r *http.Request) bool
- func Prompt(r *http.Request) string
- func SetLocation(w http.ResponseWriter, location string)
- func SetPush(w http.ResponseWriter, push bool)
- func SetRedirect(w http.ResponseWriter, location string)
- func SetRefresh(w http.ResponseWriter, refresh bool)
- func SetTrigger(w http.ResponseWriter, trigger string)
- func SetTriggerDetails(w http.ResponseWriter, trigger string, details any)
- func Target(r *http.Request) string
- func Trigger(r *http.Request) string
- func TriggerName(r *http.Request) string
Constants ¶
const ( // HeaderRequest indicates if the request was made by htmx. HeaderRequest = "HX-Request" // HeaderTriggerName is the name of the element that triggered the request. HeaderTriggerName = "HX-Trigger-Name" // HeaderTarget is the ID of the target element. HeaderTarget = "HX-Target" // HeaderPrompt is the value entered by the user when prompted via `hx-prompt`. HeaderPrompt = "HX-Prompt" // HeaderPush pushes a new URL into the browser's address bar. HeaderPush = "HX-Push" // HeaderRedirect triggers a client-side redirect to a new location. HeaderRedirect = "HX-Redirect" // HeaderLocation triggers a client-side redirect to a new location that acts as a swap. HeaderLocation = "HX-Location" // HeaderRefresh triggers a client-side full refresh of the page when set to `true`. HeaderRefresh = "HX-Refresh" // HeaderTriggerAfterSwap riggers client-side events after the swap step. // See also: https://htmx.org/headers/hx-trigger/ HeaderTriggerAfterSwap = "HX-Trigger-After-Swap" // HeaderTriggerAfterSettle triggers client-side events after the settle step. // See also: https://htmx.org/headers/hx-trigger/ HeaderTriggerAfterSettle = "HX-Trigger-After-Settle" // HeaderTrigger is the ID of the element that triggered the request. If set in a response, triggers client-side events. // See also: https://htmx.org/headers/hx-trigger/ HeaderTrigger = "HX-Trigger" )
Variables ¶
This section is empty.
Functions ¶
func FS ¶
FS provides a filesystem containing the latest build of htmx, minified. This method must not be relied on and might get removed from this package in the future without prior notice.
func IsRequest ¶
IsRequest indicates if a http.Request comes from htmx by checking if the HeaderRequest is present and equals to "true".
func SetLocation ¶
func SetLocation(w http.ResponseWriter, location string)
func SetPush ¶
func SetPush(w http.ResponseWriter, push bool)
func SetRedirect ¶
func SetRedirect(w http.ResponseWriter, location string)
func SetRefresh ¶
func SetRefresh(w http.ResponseWriter, refresh bool)
func SetTrigger ¶
func SetTrigger(w http.ResponseWriter, trigger string)
TODO(@wtfiscrq): implement SetTrigger
func SetTriggerDetails ¶
func SetTriggerDetails(w http.ResponseWriter, trigger string, details any)
TODO(@wtfiscrq): implement SetTriggerDetails
func TriggerName ¶
Types ¶
This section is empty.