diff options
author | xengineering <me@xengineering.eu> | 2023-02-11 13:46:45 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-02-11 13:46:45 +0100 |
commit | 6b52b4bbc81c64b29daff043b83e21c38f332052 (patch) | |
tree | 3a5d41f75228fe6ece3df5c109365d54b0ba6d04 /mux.go | |
parent | 312c59564700da719dbafad11c2d9f647b46d912 (diff) | |
download | ceres-6b52b4bbc81c64b29daff043b83e21c38f332052.tar ceres-6b52b4bbc81c64b29daff043b83e21c38f332052.tar.zst ceres-6b52b4bbc81c64b29daff043b83e21c38f332052.zip |
Switch to global database pointer
Passing the database pointer around is a lot of text and has no benefit.
Diffstat (limited to 'mux.go')
-rw-r--r-- | mux.go | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -5,37 +5,37 @@ import ( "net/http" ) -func indexMux(db *Database) func(http.ResponseWriter, *http.Request) { +func indexMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - indexGet(w, r, db) + indexGet(w, r) default: http.Error(w, "Bad Request", 400) } } } -func recipeMux(db *Database) func(http.ResponseWriter, *http.Request) { +func recipeMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - recipeGet(w, r, db) + recipeGet(w, r) case "POST": - recipePost(w, r, db) + recipePost(w, r) default: http.Error(w, "Bad Request", 400) } } } -func recipeEditMux(db *Database) func(http.ResponseWriter, *http.Request) { +func recipeEditMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - recipeEditGet(w, r, db) + recipeEditGet(w, r) case "POST": - recipeEditPost(w, r, db) + recipeEditPost(w, r) default: http.Error(w, "Bad Request", 400) } @@ -53,13 +53,13 @@ func recipeImageMux() func(http.ResponseWriter, *http.Request) { } } -func addRecipesMux(db *Database) func(http.ResponseWriter, *http.Request) { +func addRecipesMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": addRecipesGet(w, r) case "POST": - addRecipesPost(w, r, db) + addRecipesPost(w, r) default: http.Error(w, "Bad Request", 400) } |