Created
October 1, 2018 20:34
-
-
Save vividvilla/87fbd34d71f87478677f0d83d17197e5 to your computer and use it in GitHub Desktop.
Callbacks for simplesession
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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