diff options
Diffstat (limited to 'utils.go')
| -rw-r--r-- | utils.go | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -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 { |
