aboutsummaryrefslogtreecommitdiffstats
path: root/utils.go
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2017-06-10 19:21:54 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2017-06-10 19:21:54 -0400
commit246ce98dc8a7a55c6a9dfb850afcc69c7c8ea4f8 (patch)
treeaff48491487d8cf58e2f955f403d616a9aa7bcaf /utils.go
parent3d28f3c83dabe6049d8d189c29483ed8afcd6641 (diff)
downloadlastfm-api-246ce98dc8a7a55c6a9dfb850afcc69c7c8ea4f8.tar.gz
do not ignore error
Diffstat (limited to 'utils.go')
-rw-r--r--utils.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/utils.go b/utils.go
index 2a47905..901a7d2 100644
--- a/utils.go
+++ b/utils.go
@@ -34,16 +34,20 @@ func (app *App) GetCookie(r *http.Request, name string, dst interface{}) error {
return app.CookieHandler.Decode(name, cookie.Value, dst)
}
-func (app *App) SetCookie(w http.ResponseWriter, name string, v interface{}, exp int) {
- encoded, _ := app.CookieHandler.Encode(name, v)
- cookie := &http.Cookie{
- Name: name,
- Value: encoded,
- Path: "/",
- HttpOnly: true,
- MaxAge: exp,
+func (app *App) SetCookie(w http.ResponseWriter, name string, v interface{}, exp int) error {
+ if encoded, err := app.CookieHandler.Encode(name, v); err != nil {
+ return err
+ } else {
+ cookie := &http.Cookie{
+ Name: name,
+ Value: encoded,
+ Path: "/",
+ HttpOnly: true,
+ MaxAge: exp,
+ }
+ http.SetCookie(w, cookie)
+ return nil
}
- http.SetCookie(w, cookie)
}
func ago(t time.Time) string {