diff options
| author | xengineering <me@xengineering.eu> | 2023-04-25 17:39:48 +0200 | 
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2023-04-28 10:44:29 +0200 | 
| commit | f456fa1a6d3a6633af3b420f1eddbc1a96ffcdf1 (patch) | |
| tree | 6803e98d6370abf887301adaf26438000fa7c292 /mux.go | |
| parent | fff3d70ba494214e434083c9d0e32f3def32138f (diff) | |
| download | ceres-f456fa1a6d3a6633af3b420f1eddbc1a96ffcdf1.tar ceres-f456fa1a6d3a6633af3b420f1eddbc1a96ffcdf1.tar.zst ceres-f456fa1a6d3a6633af3b420f1eddbc1a96ffcdf1.zip | |
Introduce routing table
This removes a lot of repetative code.
Diffstat (limited to 'mux.go')
| -rw-r--r-- | mux.go | 72 | 
1 files changed, 0 insertions, 72 deletions
| @@ -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) -	} -} | 
