diff options
author | xengineering <me@xengineering.eu> | 2024-01-08 19:36:01 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-01-08 19:36:01 +0100 |
commit | ae1a31f226de5701683231afaabf0f66503ca17d (patch) | |
tree | b11a8b8c91ac41ee7ffb783de23b5c38dd9e2e6a /view/common.go | |
parent | 43e7bb10eaade56a9444ec089aa3102218231868 (diff) | |
download | ceres-ae1a31f226de5701683231afaabf0f66503ca17d.tar ceres-ae1a31f226de5701683231afaabf0f66503ca17d.tar.zst ceres-ae1a31f226de5701683231afaabf0f66503ca17d.zip |
Implement recipe editing
Diffstat (limited to 'view/common.go')
-rw-r--r-- | view/common.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/view/common.go b/view/common.go index c371fa0..b4df532 100644 --- a/view/common.go +++ b/view/common.go @@ -62,3 +62,21 @@ func HandlerHTML(prototype model.ReadableData) http.HandlerFunc { } } } + +func RecipeEditHandler(w http.ResponseWriter, r *http.Request) { + var recipe model.Recipe + var err error + + vars := mux.Vars(r) + recipe.Id = vars[`id`] + + err = recipe.FromDB() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + + err = html.ExecuteTemplate(w, `recipe-edit`, recipe) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } +} |