Documentation
¶
Index ¶
- Variables
- func DeleteCookie(w http.ResponseWriter, attributes *Attributes)
- func DeleteCookies(w http.ResponseWriter, attributesList ...*Attributes)
- func GetTimestampCookie(r *http.Request, attributes *Attributes) (*time.Time, error)
- func RenovateCookie(w http.ResponseWriter, r *http.Request, attributes *Attributes, ...) error
- func SetCookie(w http.ResponseWriter, attributes *Attributes, value string, ...)
- func SetTimestampCookie(w http.ResponseWriter, attributes *Attributes, value, expiresAt time.Time)
- type Attributes
- type NotFoundFn
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilRequest = errors.New("nil request") ErrNilAttributes = errors.New("nil cookie attributes") )
Functions ¶
func DeleteCookie ¶ added in v0.14.8
func DeleteCookie(w http.ResponseWriter, attributes *Attributes)
DeleteCookie deletes a cookie
Parameters:
- w: The HTTP response writer
- attributes: The attributes of the cookie to delete
func DeleteCookies ¶ added in v0.9.3
func DeleteCookies(w http.ResponseWriter, attributesList ...*Attributes)
DeleteCookies deletes the cookies
Parameters:
- w: The HTTP response writer
- attributesList: The list of attributes of the cookies to delete
func GetTimestampCookie ¶ added in v0.9.3
GetTimestampCookie gets a timestamp cookie
Parameters:
- r: The HTTP request
- attributes: The attributes of the cookie
Returns:
- *time.Time: The value of the cookie, or nil if not found
- error: An error if something went wrong
func RenovateCookie ¶ added in v0.9.3
func RenovateCookie( w http.ResponseWriter, r *http.Request, attributes *Attributes, expiresAt time.Time, cookieNotFoundFn NotFoundFn, ) error
RenovateCookie creates a new cookie with the same value and a new expiration time
Parameters:
- w: The HTTP response writer
- r: The HTTP request
- attributes: The attributes of the cookie
- expiresAt: The new expiration time of the cookie
- cookieNotFoundFn: The function to call if the cookie is not found
- error: An error if something went wrong
Returns:
- error: An error if something went wrong
func SetCookie ¶
func SetCookie( w http.ResponseWriter, attributes *Attributes, value string, expiresAt time.Time, )
SetCookie sets a cookie
Parameters:
- w: The HTTP response writer
- attributes: The attributes of the cookie
- value: The value of the cookie
- expiresAt: The expiration time of the cookie
func SetTimestampCookie ¶ added in v0.9.3
func SetTimestampCookie( w http.ResponseWriter, attributes *Attributes, value, expiresAt time.Time, )
SetTimestampCookie sets a cookie with a timestamp
Parameters:
- w: The HTTP response writer
- attributes: The attributes of the cookie
- value: The value of the cookie
- expiresAt: The expiration time of the cookie
Types ¶
type Attributes ¶
type Attributes struct {
Name string
Path string
Domain string
Secure bool
HTTPOnly bool
SameSite http.SameSite
}
Attributes is the structure for the attributes of a cookie
type NotFoundFn ¶ added in v0.10.0
type NotFoundFn func( w http.ResponseWriter, attributes *Attributes, err error, ) error
NotFoundFn is the function to call when a cookie is not found
Click to show internal directories.
Click to hide internal directories.