diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-01-23 11:45:07 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-01-23 11:45:07 -0800 |
commit | 964479e5ce756aa48755dc3de35b4d82326f149f (patch) | |
tree | 7376ead82555bd454ce9983404a4a91efb00cd55 /system/admin/handlers.go | |
parent | 26aa5815c50890b1c151b968ea60fce7f1c23ba5 (diff) |
adding basic auth middleware, admin/backup route, and backup routines for system, analytics, and uploads
Diffstat (limited to 'system/admin/handlers.go')
-rw-r--r-- | system/admin/handlers.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go index a28b789..a99a62c 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -19,6 +19,7 @@ import ( "github.com/ponzu-cms/ponzu/system/admin/upload" "github.com/ponzu-cms/ponzu/system/admin/user" "github.com/ponzu-cms/ponzu/system/api" + "github.com/ponzu-cms/ponzu/system/api/analytics" "github.com/ponzu-cms/ponzu/system/db" "github.com/ponzu-cms/ponzu/system/item" @@ -188,6 +189,37 @@ func configHandler(res http.ResponseWriter, req *http.Request) { } +func backupHandler(res http.ResponseWriter, req *http.Request) { + switch req.URL.Query().Get("source") { + case "system": + err := db.Backup(res) + if err != nil { + log.Println("Failed to run backup on system:", err) + res.WriteHeader(http.StatusInternalServerError) + return + } + + case "analytics": + err := analytics.Backup(res) + if err != nil { + log.Println("Failed to run backup on analytics:", err) + res.WriteHeader(http.StatusInternalServerError) + return + } + + case "uploads": + err := upload.Backup(res) + if err != nil { + log.Println("Failed to run backup on uploads:", err) + res.WriteHeader(http.StatusInternalServerError) + return + } + + default: + res.WriteHeader(http.StatusBadRequest) + } +} + func configUsersHandler(res http.ResponseWriter, req *http.Request) { switch req.Method { case http.MethodGet: |