Documentation ¶
Index ¶
Constants ¶
View Source
const ( // INFO is the info level. INFO = "info" // SUCCESS is the success level. SUCCESS = "success" // ERROR is the error level. ERROR = "error" )
Variables ¶
View Source
var DefaultErrorHandler = func(c *fiber.Ctx, err error) error { code := fiber.StatusInternalServerError var te Toast if !errors.As(err, &te) { te = Error("there has been an unexpected error") } var e *fiber.Error // if this is not a toast then use the error message if errors.As(err, &e) { code = e.Code te = Error(e.Message) } if te.Level != SUCCESS { htmx.ReSwap(c, "none") } te.SetHXTriggerHeader(c) c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8) return c.Status(code).SendString(err.Error()) }
DefaultErrorHandler is the default error handler for toasts.
Functions ¶
Types ¶
type Toast ¶
type Toast struct { // Level is the level of the toast. Level string `json:"level"` // Message is the message of the toast. Message string `json:"message"` // Code is the http status code of the toast. Code int `json:"code"` }
Toast is a message to display to the user.
func (Toast) SetHXTriggerHeader ¶ added in v1.3.24
SetHXTriggerHeader sets the HTMX trigger header.
type ToasterProps ¶ added in v1.3.24
type ToasterProps struct { // ClassNames are the class names for the toast. ClassNames htmx.ClassNames }
ToasterProps is the properties for the Toaster component.
Click to show internal directories.
Click to hide internal directories.