package main import ( "net/http" ) func indexMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": indexGet(w, r, db, templateRoot) default: http.Error(w, "Bad Request", 400) } } } func recipeMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": recipeGet(w, r, db, templateRoot) case "POST": recipePost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } func recipeEditMux(db *Database, templateRoot string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": recipeEditGet(w, r, db, templateRoot) case "POST": recipeEditPost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } func recipeImageMux(storage string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": recipeImageGet(w, r, storage) default: http.Error(w, "Bad Request", 400) } } } func addRecipesMux(db *Database, storage string, static string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": addRecipesGet(w, r, static) case "POST": addRecipesPost(w, r, db) default: http.Error(w, "Bad Request", 400) } } } func staticStyleMux(file string, static string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": staticGet(w, r, file, static) default: http.Error(w, "Bad Request", 400) } } } func faviconMux(file string, static string) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": staticGet(w, r, file, static) default: http.Error(w, "Bad Request", 400) } } }