From 6b52b4bbc81c64b29daff043b83e21c38f332052 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 11 Feb 2023 13:46:45 +0100 Subject: Switch to global database pointer Passing the database pointer around is a lot of text and has no benefit. --- mux.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'mux.go') diff --git a/mux.go b/mux.go index 3aed42d..2b37286 100644 --- a/mux.go +++ b/mux.go @@ -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) } -- cgit v1.2.3-70-g09d2