diff options
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -7,6 +7,7 @@ import ( "net/http" "xengineering.eu/ceres/controller" + "xengineering.eu/ceres/model" "xengineering.eu/ceres/view" "github.com/gorilla/mux" @@ -19,7 +20,7 @@ type Server struct { //go:embed view/static/simple.css/simple.css view/static/ceres.js var static embed.FS -func NewServer(addr string) Server { +func NewServer(addr string, db *model.DB) Server { var r *mux.Router = mux.NewRouter() r.PathPrefix("/static/"). @@ -27,13 +28,13 @@ func NewServer(addr string) Server { r.HandleFunc("/version", view.VersionRead(version)).Methods(`GET`) - r.HandleFunc("/recipes", view.RecipesRead).Methods(`GET`) + r.HandleFunc("/recipes", view.RecipesRead(db)).Methods(`GET`) r.HandleFunc("/recipe/create", view.RecipeCreate).Methods(`GET`) - r.HandleFunc("/recipe", controller.RecipeCreate).Methods(`POST`) - r.HandleFunc("/recipe/{id:[0-9]+}", view.RecipeRead).Methods(`GET`) - r.HandleFunc("/recipe/{id:[0-9]+}", controller.RecipeUpdate).Methods(`POST`) - r.HandleFunc("/recipe/{id:[0-9]+}", controller.RecipeDelete).Methods(`DELETE`) + r.HandleFunc("/recipe", controller.RecipeCreate(db)).Methods(`POST`) + r.HandleFunc("/recipe/{id:[0-9]+}", view.RecipeRead(db)).Methods(`GET`) + r.HandleFunc("/recipe/{id:[0-9]+}", controller.RecipeUpdate(db)).Methods(`POST`) + r.HandleFunc("/recipe/{id:[0-9]+}", controller.RecipeDelete(db)).Methods(`DELETE`) r.HandleFunc("/favicon.ico", view.FaviconRead).Methods(`GET`) |