diff options
Diffstat (limited to 'view/recipes.go')
-rw-r--r-- | view/recipes.go | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/view/recipes.go b/view/recipes.go index e7153cd..8cd107e 100644 --- a/view/recipes.go +++ b/view/recipes.go @@ -6,21 +6,23 @@ import ( "xengineering.eu/ceres/model" ) -func RecipesRead(db *model.DB) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - recipes := make(model.Recipes, 0) +func RecipesRead(db *model.DB) http.Handler { + return http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + recipes := make(model.Recipes, 0) - var obj model.Object = &recipes - err := db.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 + } + }, + ) } |