From f456fa1a6d3a6633af3b420f1eddbc1a96ffcdf1 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 25 Apr 2023 17:39:48 +0200 Subject: Introduce routing table This removes a lot of repetative code. --- mux.go | 72 ------------------------------------------------------------------ 1 file changed, 72 deletions(-) delete mode 100644 mux.go (limited to 'mux.go') diff --git a/mux.go b/mux.go deleted file mode 100644 index 9fb0dad..0000000 --- a/mux.go +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "net/http" -) - -func indexMux(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - indexGet(w, r) - default: - http.Error(w, "Bad Request", 400) - } -} - -func recipeMux(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - recipeGet(w, r) - default: - http.Error(w, "Bad Request", 400) - } -} - -func recipeEditMux(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - recipeEditGet(w, r) - case "POST": - recipeEditPost(w, r) - default: - http.Error(w, "Bad Request", 400) - } -} - -func recipeConfirmDeletionMux(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - recipeConfirmDeletionGet(w, r) - case "POST": - recipeConfirmDeletionPost(w, r) - default: - http.Error(w, "Bad Request", 400) - } -} - -func addRecipesMux(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - addRecipesGet(w, r) - default: - http.Error(w, "Bad Request", 400) - } -} - -func staticStyleMux(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(w http.ResponseWriter, r *http.Request) { - switch r.Method { - case "GET": - staticGet(w, r, "favicon.ico") - default: - http.Error(w, "Bad Request", 400) - } -} -- cgit v1.2.3-70-g09d2