httputil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

Package httputil provides HTTP handler utilities shared across modules.

Index

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 ErrorInline

func ErrorInline(status int, title, message string) templ.Component

func ErrorPage

func ErrorPage(data ErrorPageData) templ.Component

func ErrorPageCard

func ErrorPageCard(data ErrorPageData) templ.Component

func Forbidden

func Forbidden(w http.ResponseWriter, r *http.Request)

func InternalServerError

func InternalServerError(w http.ResponseWriter, r *http.Request)

func NotFound

func NotFound(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 Render

func Render(w http.ResponseWriter, r *http.Request, c templ.Component)

Render writes a templ component to the response, logging any error.

func ValidateURL

func ValidateURL(raw string) error

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

type ErrorPageData

type ErrorPageData struct {
	Status       int
	Title        string
	Message      string
	RequestID    string
	PrimaryHref  string
	PrimaryLabel string
}

Jump to

Keyboard shortcuts

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