diff options
Diffstat (limited to 'controller')
| -rw-r--r-- | controller/recipe.go | 17 | 
1 files changed, 16 insertions, 1 deletions
| diff --git a/controller/recipe.go b/controller/recipe.go index 4d5de53..259e3bc 100644 --- a/controller/recipe.go +++ b/controller/recipe.go @@ -6,9 +6,11 @@ import (  	"net/http"  	"xengineering.eu/ceres/model" + +	"github.com/gorilla/mux"  ) -func Recipe(w http.ResponseWriter, r *http.Request) { +func RecipeUpdate(w http.ResponseWriter, r *http.Request) {  	buf, err := io.ReadAll(r.Body)  	if err != nil {  		http.Error(w, err.Error(), http.StatusInternalServerError) @@ -30,3 +32,16 @@ func Recipe(w http.ResponseWriter, r *http.Request) {  	http.Redirect(w, r, "/recipe/" + recipe.Id, http.StatusSeeOther)  } + +func RecipeDelete(w http.ResponseWriter, r *http.Request) { +	recipe := model.Recipe{} +	recipe.Id = mux.Vars(r)[`id`] + +	err := recipe.Delete() +	if err != nil { +		http.Error(w, err.Error(), http.StatusInternalServerError) +		return +	} + +	http.Redirect(w, r, "/recipes", http.StatusSeeOther) +} | 
