httpflashes

package module
v0.0.0-...-18f0c52 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Module for displaying outputting messages to users in the form of HTML flashes. Also contains functions to redirect requests with flash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpError

func HttpError(w http.ResponseWriter, code int, text string, level LogLevel, err error, toLog ...any)

Logs and writes error. Accepts http.ResponseWriter, http error code, message text, log level, error and additional parameters of type slog.Attr

func HttpSuccess

func HttpSuccess(w http.ResponseWriter, text string)

Writes 200 OK response with flash message.

func RedirectError

func RedirectError(w http.ResponseWriter, r *http.Request, redirect func(http.ResponseWriter, *http.Request), text string, level LogLevel, err error, toLog ...any)

Logs and redirects error. Besides http.ResponseWriter, *http.Request, and the redirect function, it accepts message text, log level, error and additional parameters of type slog.Attr

func SetSuccessMessage

func SetSuccessMessage(w http.ResponseWriter, text string)

Sets success message on http.ResponseWriter

Types

type LogLevel

type LogLevel int

Enum describing log level - corresponds to log/slog levels

const (
	Debug LogLevel = iota
	Info
	Warn
	Error
)

type Message

type Message struct {
	Class string `json:"class"`
	Text  string `json:"text"`
}

Struct containing a message to be displayed and the class that the message should have.

Jump to

Keyboard shortcuts

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