diff options
Diffstat (limited to 'view/recipes.go')
-rw-r--r-- | view/recipes.go | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/view/recipes.go b/view/recipes.go index fe995b2..e7153cd 100644 --- a/view/recipes.go +++ b/view/recipes.go @@ -6,19 +6,21 @@ import ( "xengineering.eu/ceres/model" ) -func RecipesRead(w http.ResponseWriter, r *http.Request) { - recipes := make(model.Recipes, 0) +func RecipesRead(db *model.DB) func(http.ResponseWriter, *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + recipes := make(model.Recipes, 0) - var obj model.Object = &recipes - err := model.Transaction(obj.Read) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } + var obj model.Object = &recipes + err := db.Transaction(obj.Read) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } - err = html.ExecuteTemplate(w, "recipes", recipes) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return + err = html.ExecuteTemplate(w, "recipes", recipes) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } } } |