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.
Click to show internal directories.
Click to hide internal directories.