htmlform

package
v0.0.0-...-f89fa1c Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package htmlform provides helper functions for working with HTML forms.

Index

Constants

View Source
const (

	// CSRFKey is the HTML form key used to store a CSRF token which
	// can be validated using CSRFCheck.
	CSRFKey = "_csrf"
	// DateFormat is the format used to render dates in HTML forms.
	DateFormat = time.DateOnly
	// DeskKey is the HTML form key used to store the desk being booked.
	DeskKey = "desk"
	// DateKey is the HTML form key used to store the date being booked.
	// Any dates should be passed in DateFormat format.
	DateKey = "day"
)

Variables

This section is empty.

Functions

func CSRFCheck

func CSRFCheck(w http.ResponseWriter, r *http.Request) bool

CSRFCheck validates a CSRF token from a form submission against the CSRF cookie set by CSRFProtect. It returns true if the token is valid, false otherwise. If the token is valid, the cookie will be cleared in the passed response writer.

func CSRFProtect

func CSRFProtect(w http.ResponseWriter) string

CSRFProtect generates a CSRF token and sets a cookie with it. The cookie will be added to the response headers, and the token will be returned and should be added to the form using the CSRFKey key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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