URL: DELETE /api/session
(w http.ResponseWriter, r *http.Request)
| 80 | |
| 81 | // URL: DELETE /api/session |
| 82 | func (api *API) DeleteSession(w http.ResponseWriter, r *http.Request) error { |
| 83 | session, _ := api.sessions.Get(r, "auth") |
| 84 | if !session.IsNew { |
| 85 | session.Options.MaxAge = -1 |
| 86 | err := session.Save(r, w) |
| 87 | if err != nil { |
| 88 | return err |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return respond(w, http.StatusOK, envelope{Data: true}) |
| 93 | } |
| 94 | |
| 95 | // Authorize is middleware that aborts the request if unauthorized |
| 96 | func (api *API) Authorize(next http.Handler) http.Handler { |