diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-03-14 17:06:07 +0100 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-14 16:06:07 +0000 |
commit | fa47132b8f1d6d889450021f6afbdc903208ac41 (patch) | |
tree | 128ff3b7563e3fcef45c0ddc07704335566eb881 /api4/system.go | |
parent | a1994cf7ce3d660edd4be4a470b1239443a99275 (diff) | |
download | chat-fa47132b8f1d6d889450021f6afbdc903208ac41.tar.gz chat-fa47132b8f1d6d889450021f6afbdc903208ac41.tar.bz2 chat-fa47132b8f1d6d889450021f6afbdc903208ac41.zip |
[APIV4] POST /caches/invalidate - endpoint for apiV4 (#5756)
Diffstat (limited to 'api4/system.go')
-rw-r--r-- | api4/system.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/api4/system.go b/api4/system.go index 32c010d82..d33be0c66 100644 --- a/api4/system.go +++ b/api4/system.go @@ -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) +} |