summaryrefslogtreecommitdiffstats
path: root/api4/system.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-03-13 16:47:33 +0100
committerGeorge Goldberg <george@gberg.me>2017-03-13 15:47:33 +0000
commit27d2c1f6febdc6b80f60837086ebe0c08f975147 (patch)
treecb2b6ace91234817721170c8d3b9a0ffceeacfed /api4/system.go
parent38958d9ac4f415d9ae99dfcdb53bfdc355d96764 (diff)
downloadchat-27d2c1f6febdc6b80f60837086ebe0c08f975147.tar.gz
chat-27d2c1f6febdc6b80f60837086ebe0c08f975147.tar.bz2
chat-27d2c1f6febdc6b80f60837086ebe0c08f975147.zip
Add implementation for POST /database/recycle apiV4 - Recycle database connection (#5717)
Diffstat (limited to 'api4/system.go')
-rw-r--r--api4/system.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/api4/system.go b/api4/system.go
index f7a3918a5..04275f57f 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -18,6 +18,7 @@ func InitSystem() {
BaseRoutes.System.Handle("/ping", ApiHandler(getSystemPing)).Methods("GET")
BaseRoutes.ApiRoot.Handle("/config", ApiSessionRequired(getConfig)).Methods("GET")
BaseRoutes.ApiRoot.Handle("/email/test", ApiSessionRequired(testEmail)).Methods("POST")
+ BaseRoutes.ApiRoot.Handle("/database/recycle", ApiSessionRequired(databaseRecycle)).Methods("POST")
}
func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -51,3 +52,15 @@ func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Write([]byte(cfg.ToJson()))
}
+
+func databaseRecycle(c *Context, w http.ResponseWriter, r *http.Request) {
+
+ if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
+ c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
+ return
+ }
+
+ app.RecycleDatabaseConnection()
+
+ ReturnStatusOK(w)
+}