Documentation ¶
Index ¶
- Constants
- func ClearCookie(w http.ResponseWriter, cookieName, cookiePath string)
- func RandomCookieFriendlyString(length int) string
- func RandomHumanFriendlyString(length int) string
- func RandomString(length int) string
- func SecureCookie(req *http.Request, name, cookieSecret string) (string, bool)
- func Seed()
- func SetCookiePath(w http.ResponseWriter, name, value string, age int64, path string)
- func SetCookiePathWithFlags(w http.ResponseWriter, name, value string, age int64, path string, ...)
- func SetHeader(w http.ResponseWriter, hdr, val string, unique bool)
- func SetSecureCookiePath(w http.ResponseWriter, name, val string, age int64, path string, ...)
- func SetSecureCookiePathWithFlags(w http.ResponseWriter, name, val string, age int64, path, cookieSecret string, ...)
- func Signature(key string, val []byte, timestamp string) string
Constants ¶
const ( // Version number. Stable API within major version numbers. Version = 2.0 // DefaultCookieTime represent how long login cookies should last, by deafault DefaultCookieTime = 24 * 3600 // 24 hours )
Variables ¶
This section is empty.
Functions ¶
func ClearCookie ¶
func ClearCookie(w http.ResponseWriter, cookieName, cookiePath string)
ClearCookie clears the cookie with the given cookie name and a corresponding path. The cookie is cleared by setting the expiration date to 1970-01-01. Note that browsers *may* be configured to not delete the cookie.
func RandomCookieFriendlyString ¶
RandomCookieFriendlyString generates a random, but cookie-friendly, string of the given length.
func RandomHumanFriendlyString ¶
RandomHumanFriendlyString generates a random, but human-friendly, string of
- the given length. It should be possible to read out loud and send in an email
- without problems. The string alternates between vowels and consontants. *
- Google Translate believes the output is Samoan. *
- Example output for length 10: ookeouvapu
func RandomString ¶
RandomString generates a random string of a given length.
func SecureCookie ¶
SecureCookie retrieves a secure cookie from a HTTP request
func SetCookiePath ¶
func SetCookiePath(w http.ResponseWriter, name, value string, age int64, path string)
SetCookiePath sets a cookie with an explicit path. age is the time-to-live, in seconds (0 means forever).
func SetCookiePathWithFlags ¶
func SetCookiePathWithFlags(w http.ResponseWriter, name, value string, age int64, path string, secure, httponly bool)
SetCookiePathWithFlags sets a cookie with an explicit path.
- age is the time-to-live, in seconds (0 means forever). *
- The secure and httponly flags are documented here:
- https://golang.org/pkg/net/http/#Cookie
func SetHeader ¶
func SetHeader(w http.ResponseWriter, hdr, val string, unique bool)
SetHeader sets cookies in the HTTP header
func SetSecureCookiePath ¶
func SetSecureCookiePath(w http.ResponseWriter, name, val string, age int64, path string, cookieSecret string)
SetSecureCookiePath creates and sets a secure cookie with an explicit path. age is the time-to-live, in seconds (0 means forever).
func SetSecureCookiePathWithFlags ¶
func SetSecureCookiePathWithFlags(w http.ResponseWriter, name, val string, age int64, path, cookieSecret string, secure, httponly bool)
SetSecureCookiePathWithFlags creates and sets a secure cookie with an explicit path.
- age is the time-to-live, in seconds (0 means forever). *
- The secure and httponly flags are documented here:
- https://golang.org/pkg/net/http/#Cookie
Types ¶
This section is empty.