hxfiber

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentUrl

func GetCurrentUrl(ctx *fiber.Ctx) string

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

func GetPrompt(ctx *fiber.Ctx) string

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

func GetTarget(ctx *fiber.Ctx) string

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

func GetTrigger(ctx *fiber.Ctx) string

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

func GetTriggerName(ctx *fiber.Ctx) string

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

func IsBoosted(ctx *fiber.Ctx) bool

IsBoosted checks the HX-Boosted header

Returns true if the request is a boosted request

func IsHistoryRestoreRequest

func IsHistoryRestoreRequest(ctx *fiber.Ctx) bool

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

func IsHtmx(ctx *fiber.Ctx) bool

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

func IsRequest(ctx *fiber.Ctx) bool

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

func Response(ctx *fiber.Ctx, options ...hx.ResponseOption) (*hx.HtmxResponse, error)

Response modifies the fiber.Ctx to add HTMX headers and status codes.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL