Documentation
¶
Overview ¶
templ: version: v0.3.1020
Package httputil provides HTTP handler utilities shared across modules.
Index ¶
- Variables
- func Error(w http.ResponseWriter, r *http.Request, status int)
- func ErrorInline(status int, title, message string) templ.Component
- func ErrorPage(data ErrorPageData) templ.Component
- func ErrorPageCard(data ErrorPageData) templ.Component
- func Forbidden(w http.ResponseWriter, r *http.Request)
- func InternalServerError(w http.ResponseWriter, r *http.Request)
- func NotFound(w http.ResponseWriter, r *http.Request)
- func RedirectWithFlash(w http.ResponseWriter, r *http.Request, target, flash, flashType string)
- func Render(w http.ResponseWriter, r *http.Request, c templ.Component)
- func ValidateURL(raw string) error
- type ErrorPageData
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrURLInvalidScheme = errors.New("URL scheme not allowed; use http or https") ErrURLMissingHost = errors.New("URL must include a host") )
Sentinel errors for URL validation.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, r *http.Request, status int)
Error writes a localized error response for full-page and HTMX requests.
func ErrorPage ¶
func ErrorPage(data ErrorPageData) templ.Component
func ErrorPageCard ¶
func ErrorPageCard(data ErrorPageData) templ.Component
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter, r *http.Request)
func RedirectWithFlash ¶
func RedirectWithFlash(w http.ResponseWriter, r *http.Request, target, flash, flashType string)
RedirectWithFlash redirects to target with flash message query params.
func ValidateURL ¶
ValidateURL parses raw and returns an error if it is not a valid http or https URL with a non-empty host. Use this for any URL accepted from user input before storing or rendering it as a link.
Types ¶
Click to show internal directories.
Click to hide internal directories.