Documentation
¶
Index ¶
- func GetCurrentUrl(ctx *gin.Context) string
- func GetPrompt(ctx *gin.Context) string
- func GetTarget(ctx *gin.Context) string
- func GetTrigger(ctx *gin.Context) string
- func GetTriggerName(ctx *gin.Context) string
- func IsBoosted(ctx *gin.Context) bool
- func IsHistoryRestoreRequest(ctx *gin.Context) bool
- func IsHtmx(ctx *gin.Context) bool
- func IsRequest(ctx *gin.Context) bool
- func Response(ctx *gin.Context, options ...hx.ResponseOption) (*hx.HtmxResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUrl ¶
GetCurrentUrl extracts the HX-Current-URL header from an HTTP request.
It returns the current URL of the browser if the header exists. If the header is not present, it returns an empty string.
func GetPrompt ¶
GetPrompt extracts the HX-Prompt header from an HTTP request.
It returns the user response to an Hx-Prompt if the header exists. If the header is not present, it returns an empty string.
func GetTarget ¶
GetTarget extracts the HX-Target header from an HTTP request.
It returns the ID of the target element if the header exists. If the header is not present, it returns an empty string.
func GetTrigger ¶
GetTrigger extracts the HX-Trigger header from an HTTP request.
It returns the ID of the trigger element if the header exists. If the header is not present, it returns an empty string.
func GetTriggerName ¶
GetTriggerName extracts the HX-Trigger-Name header from an HTTP request.
It returns the name of the triggered element if the header exists. If the header is not present, it returns an empty string.
func IsBoosted ¶
IsBoosted checks the HX-Boosted header
Returns true if the request is a boosted request
func IsHistoryRestoreRequest ¶
IsHistoryRestoreRequest determines if an HTTP request is a history restore request.
It checks the presence of the HX-History-Restore-Request header in the request. Returns true if the header is present, otherwise returns false.
func IsHtmx ¶
IsHtmx determines if an HTTP request is an HTMX request.
Does the same thing as IsRequest, only with a more user-friendly name.
func IsRequest ¶
IsRequest determines if an HTTP request is an HTMX request.
It checks the presence of the HX-Request header in the request. Returns true if the header is present, otherwise returns false.
func Response ¶
Response modifies the gin.Context to add HTMX headers and status codes.
This will set the HTMX headers but will not set the Status Code. Use the returned response to set the Status Code later with `response.StatusCode()`.
The following options are available:
- Status(int) | StatusStopPolling: Sets the HTTP status code of the HTMX response.
- Location(path, ...properties): Enables client-side redirection without a full page reload.
- PushUrl(string): Pushes a new URL into the history stack.
- Redirect(string): Performs a client-side redirect with a full page reload.
- Refresh(bool): If set to "true", triggers a full refresh of the client-side page.
- ReplaceUrl(string): Replaces the current URL in the location bar.
- Reswap(string) | {Swap constants}: Specifies how the response will be swapped.
- Retarget(string): A CSS selector to update the target of the content update to a different page element.
- Reselect(string): A CSS selector to select a part of the response to be swapped in, overriding existing hx-select on the triggering element.
- Trigger(...events): Triggers client-side events.
- TriggerAfterSettle(...events): Triggers client-side events after the settle step.
- TriggerAfterSwap(...events): Triggers client-side events after the swap step.
Types ¶
This section is empty.