(w http.ResponseWriter, r *http.Request)
| 10 | ) |
| 11 | |
| 12 | func clearCache(w http.ResponseWriter, r *http.Request) { |
| 13 | currentUser := helpers.GetFromContext(r, "user").(*db.User) |
| 14 | |
| 15 | if !currentUser.Admin { |
| 16 | helpers.WriteJSON(w, http.StatusForbidden, map[string]string{ |
| 17 | "error": "User must be admin", |
| 18 | }) |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | err := util.Config.ClearTmpDir() |
| 23 | if err != nil { |
| 24 | log.Error(err) |
| 25 | helpers.WriteJSON(w, http.StatusInternalServerError, map[string]string{ |
| 26 | "error": "Can not clear cache", |
| 27 | }) |
| 28 | return |
| 29 | } |
| 30 | |
| 31 | w.WriteHeader(http.StatusNoContent) |
| 32 | } |
nothing calls this directly
no test coverage detected