Skip to content

Instantly share code, notes, and snippets.

@vividvilla
Created October 1, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vividvilla/87fbd34d71f87478677f0d83d17197e5 to your computer and use it in GitHub Desktop.
Save vividvilla/87fbd34d71f87478677f0d83d17197e5 to your computer and use it in GitHub Desktop.
Callbacks for simplesession
func getCookie(name string, r interface{}) (*http.Cookie, error) {
rd := r.(*http.Request)
cookie, err := rd.Cookie(name)
if err != nil {
return nil, err
}
return cookie, nil
}
func setCookie(cookie *http.Cookie, w interface{}) error {
// Get write interface registered using `Acquire` method in handlers.
wr := w.(http.ResponseWriter)
http.SetCookie(wr, cookie)
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment