Backend update.

This commit is contained in:
Jesse Malotaux 2025-04-28 10:20:13 +02:00
parent f49630558d
commit 90bf6be882
9 changed files with 66 additions and 28 deletions

View file

@ -128,3 +128,27 @@ func PlayMacro(data string, w http.ResponseWriter, r *http.Request) {
return
}
}
func OpenMacro(w http.ResponseWriter, r *http.Request) {
var req structs.MacroRequest
err := json.NewDecoder(r.Body).Decode(&req)
if err != nil {
MCRMLog("OpenMacro Decode Error: ", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
var filename = helper.FormatMacroFileName(req.Macro)
macroFile, err := helper.ReadMacroFile(fmt.Sprintf("../macros/%s.json", filename))
if err != nil {
MCRMLog("OpenMacro ReadMacroFile Error: ", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(macroFile)
}