mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Small update to delete functionality
This commit is contained in:
parent
922b2bc4f5
commit
9e0337a2be
1 changed files with 24 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -119,7 +120,29 @@ func ListMacros(w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(macroList)
|
json.NewEncoder(w).Encode(macroList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteMacro(w http.ResponseWriter, r *http.Request) {}
|
func DeleteMacro(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req structs.MacroRequest
|
||||||
|
|
||||||
|
err := json.NewDecoder(r.Body).Decode(&req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
MCRMLog("DeleteMacro Decode Error: ", err)
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = helper.FormatMacroFileName(req.Macro)
|
||||||
|
|
||||||
|
err = os.Remove("../macros/" + filename + ".json")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
MCRMLog("DeleteMacro Remove Error: ", err)
|
||||||
|
json.NewEncoder(w).Encode(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Println("Deleted Macro:", req.Macro)
|
||||||
|
json.NewEncoder(w).Encode(true)
|
||||||
|
}
|
||||||
|
|
||||||
func PlayMacro(data string, w http.ResponseWriter, r *http.Request) {
|
func PlayMacro(data string, w http.ResponseWriter, r *http.Request) {
|
||||||
req := &structs.MacroRequest{}
|
req := &structs.MacroRequest{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue