}
func listService(rw http.ResponseWriter, req *http.Request) {
+ if !requestIsPOST(rw, req) {
+ return
+ }
+
files, err := ListPath(req.FormValue("path"))
if err != nil {
httpError(rw, err.Error(), http.StatusNotFound)
}
func removeService(rw http.ResponseWriter, req *http.Request) {
+ if !requestIsPOST(rw, req) {
+ return
+ }
+
err := RemovePath(req.FormValue("path"))
if err != nil {
httpError(rw, err.Error(), http.StatusNotFound)
}
func moveService(rw http.ResponseWriter, req *http.Request) {
+ if !requestIsPOST(rw, req) {
+ return
+ }
+
source := req.FormValue("source")
target := req.FormValue("target")
err := MovePath(source, target)
}
func mkdirService(rw http.ResponseWriter, req *http.Request) {
+ if !requestIsPOST(rw, req) {
+ return
+ }
+
path := req.FormValue("path")
err := MakeDir(path)
if err != nil {
}
func tvRenameService(rw http.ResponseWriter, req *http.Request) {
+ if !requestIsPOST(rw, req) {
+ return
+ }
+
newPath, err := RenameTVEpisode(req.FormValue("path"))
if err != nil {
httpError(rw, err.Error(), http.StatusBadRequest)
}
}
+func requestIsPOST(rw http.ResponseWriter, req *http.Request) bool {
+ if req.Method != "POST" {
+ httpError(rw, "Service requests must be sent via POST", http.StatusMethodNotAllowed)
+ return false
+ }
+ return true
+}
+
func RunBackEnd(c *config.Configuration) {
gConfig = c