Documentation ¶
Index ¶
- Constants
- func CurrentURL(r *http.Request) (string, bool)
- func IsAnyHtmxRequest(r *http.Request) bool
- func IsBoostedRequest(r *http.Request) bool
- func IsHistoryRestoreRequest(r *http.Request) bool
- func IsHtmxRequest(r *http.Request) bool
- func Prompt(r *http.Request) (string, bool)
- func Target(r *http.Request) (string, bool)
- func Trigger(r *http.Request) (string, bool)
- func TriggerName(r *http.Request) (string, bool)
Constants ¶
const ( // HXBoosted indicates the request is an HTMX boosted request. HXBoosted = "HX-Boosted" // HXCurrentURL is the current URL of the browser HXCurrentURL = "HX-Current-URL" // HXHistoryRestoreRequest indicates the request is a history restore request due to a miss in the local history cache HXHistoryRestoreRequest = "HX-History-Restore-Request" // HXPrompt is the user response to an hx-prompt HXPrompt = "HX-Prompt" // HXRequest indicates the request is an HTMX request HXRequest = "HX-Request" // HXTarget is the ID of the target element, if any HXTarget = "HX-Target" // HXTriggerName is the name of the triggered element HXTriggerName = "HX-Trigger-Name" )
HTMX Request Headers
const ( // HXLocation allows you to do a client-side redirect without a full page reload (similar to a boost) HXLocation = "HX-Location" // HXPushURL pushes the URL into the browser history stack HXPushURL = "HX-Push-URL" // HXRedirect allows you to do a client-side redirect as a full page reload HXRedirect = "HX-Redirect" // HXRefresh allows you to refresh the page as a full page reload HXRefresh = "HX-Refresh" // HXReplaceURL replaces the URL in the browser location bar HXReplaceURL = "HX-Replace-URL" // HXReswap allows you to specify how the response will be swapped in by HTMX HXReswap = "HX-Reswap" // HXRetarget is a CSS selector that updates the target of the content to update by HTMX HXRetarget = "HX-Retarget" // HXReselect is a CSS selector that indicates which part of the response should be swapped in. Overrides existing hx-swap values on the triggering element. HXReselect = "HX-ReSelect" // HXTriggerAfterSettle allows you to trigger client-side-events after the settle phase HXTriggerAfterSettle = "HX-Trigger-After-Settle" // HXTriggerAfterSwap allows you to trigger client-side-events after the swap phase HXTriggerAfterSwap = "HX-Trigger-After-Swap" )
HTMX Response Headers
const (
// HXTrigger is the ID of the triggered element when used in a request. As a response header, it can be used to trigger client-side events.
HXTrigger = "HX-Trigger"
)
Dual-use Headers (request and response)
Variables ¶
This section is empty.
Functions ¶
func CurrentURL ¶
CurrentURL returns the HX-Current-URL header, if it exists
func IsAnyHtmxRequest ¶
IsAnyHtmxRequest returns true if the current request is either an HX/HTMX request or boosted.
func IsBoostedRequest ¶
IsBoostedRequest returns true if the current request is boosted by the HX-Boosted header.
func IsHistoryRestoreRequest ¶
IsHistoryRestoreRequest returns true if the current request contains the HX-History-Restore header
func IsHtmxRequest ¶
IsHtmxRequest returns true if the current request is an HX/HTMX request, but not boosted. This distinguishes between a standard HTMX request and a boosted request as the server may need to differentiate between the two. HTMX sends a HX-Request header along with HX-Boosted, so it is not enough to check the HX-Request header.
Types ¶
This section is empty.