MCPcopy
hub / github.com/semaphoreui/semaphore / clearCache

Function clearCache

api/cache.go:12–32  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

10)
11
12func 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}

Callers

nothing calls this directly

Calls 4

GetFromContextFunction · 0.92
WriteJSONFunction · 0.92
ClearTmpDirMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected