diff options
Diffstat (limited to 'view/recipe.go')
-rw-r--r-- | view/recipe.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/view/recipe.go b/view/recipe.go index 0b545d9..52b7a7e 100644 --- a/view/recipe.go +++ b/view/recipe.go @@ -12,7 +12,20 @@ func RecipeRead(w http.ResponseWriter, r *http.Request) { recipe := model.Recipe{} recipe.Id = mux.Vars(r)[`id`] - err := recipe.Read() + tx, err := model.NewTx() + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + err = recipe.Read(tx) + if err != nil { + model.Rollback(tx) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + err = tx.Commit() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return |