[APIV4] POST /caches/invalidate - endpoint for apiV4 (#5756)

Этот коммит содержится в:
Carlos Tadeu Panato Junior
2017-03-14 17:06:07 +01:00
коммит произвёл George Goldberg
родитель a1994cf7ce
Коммит fa47132b8f
3 изменённых файлов: 48 добавлений и 1 удалений

Просмотреть файл

@@ -20,6 +20,7 @@ func InitSystem() {
BaseRoutes.ApiRoot.Handle("/config/reload", ApiSessionRequired(configReload)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/email/test", ApiSessionRequired(testEmail)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/database/recycle", ApiSessionRequired(databaseRecycle)).Methods("POST")
BaseRoutes.ApiRoot.Handle("/caches/invalidate", ApiSessionRequired(invalidateCaches)).Methods("POST")
}
func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -77,3 +78,19 @@ func databaseRecycle(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
func invalidateCaches(c *Context, w http.ResponseWriter, r *http.Request) {
if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
return
}
err := app.InvalidateAllCaches()
if err != nil {
c.Err = err
return
}
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}