diff options
author | xengineering <me@xengineering.eu> | 2023-02-11 13:02:41 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-02-11 13:02:41 +0100 |
commit | 7e517ada827abc2658bb07347bc656c10860e091 (patch) | |
tree | 2e7274381f5fe9b351407868efb36232e6a95b1d /mux.go | |
parent | 8e166f100697c5a497aa68349c20a6cb88b5503f (diff) | |
download | ceres-7e517ada827abc2658bb07347bc656c10860e091.tar ceres-7e517ada827abc2658bb07347bc656c10860e091.tar.zst ceres-7e517ada827abc2658bb07347bc656c10860e091.zip |
Switch webserver to global config struct
Diffstat (limited to 'mux.go')
-rw-r--r-- | mux.go | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -5,22 +5,22 @@ import ( "net/http" ) -func indexMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { +func indexMux(db *Database) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - indexGet(w, r, db, templateRoot) + indexGet(w, r, db) default: http.Error(w, "Bad Request", 400) } } } -func recipeMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { +func recipeMux(db *Database) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - recipeGet(w, r, db, templateRoot) + recipeGet(w, r, db) case "POST": recipePost(w, r, db) default: @@ -29,11 +29,11 @@ func recipeMux(db *Database, templateRoot string) func(http.ResponseWriter, *htt } } -func recipeEditMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { +func recipeEditMux(db *Database) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - recipeEditGet(w, r, db, templateRoot) + recipeEditGet(w, r, db) case "POST": recipeEditPost(w, r, db) default: @@ -42,22 +42,22 @@ func recipeEditMux(db *Database, templateRoot string) func(http.ResponseWriter, } } -func recipeImageMux(storage string) func(http.ResponseWriter, *http.Request) { +func recipeImageMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - recipeImageGet(w, r, storage) + recipeImageGet(w, r) default: http.Error(w, "Bad Request", 400) } } } -func addRecipesMux(db *Database, storage string, static string) func(http.ResponseWriter, *http.Request) { +func addRecipesMux(db *Database) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - addRecipesGet(w, r, static) + addRecipesGet(w, r) case "POST": addRecipesPost(w, r, db) default: @@ -66,22 +66,22 @@ func addRecipesMux(db *Database, storage string, static string) func(http.Respon } } -func staticStyleMux(file string, static string) func(http.ResponseWriter, *http.Request) { +func staticStyleMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - staticGet(w, r, file, static) + staticGet(w, r, "style.css") default: http.Error(w, "Bad Request", 400) } } } -func faviconMux(file string, static string) func(http.ResponseWriter, *http.Request) { +func faviconMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - staticGet(w, r, file, static) + staticGet(w, r, "favicon.ico") default: http.Error(w, "Bad Request", 400) } |