package main import ( "net/http" ) 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) default: http.Error(w, "Bad Request", 400) } } } 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) case "POST": recipePost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } 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) case "POST": recipeEditPost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } func recipeImageMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": recipeImageGet(w, r) default: http.Error(w, "Bad Request", 400) } } } 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) case "POST": addRecipesPost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } func staticStyleMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": staticGet(w, r, "style.css") default: http.Error(w, "Bad Request", 400) } } } func faviconMux() func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": staticGet(w, r, "favicon.ico") default: http.Error(w, "Bad Request", 400) } } }