diff options
author | xengineering <me@xengineering.eu> | 2024-02-15 19:43:36 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-02-15 19:58:08 +0100 |
commit | 62e735a0ff2a05c5455abc1f27d1d14167158175 (patch) | |
tree | 463f08b05c312f50ca636a9619d9d5047ee61f8c | |
parent | 246687318e03fb649c30c4510e264e65b25ec6da (diff) | |
download | ceres-62e735a0ff2a05c5455abc1f27d1d14167158175.tar ceres-62e735a0ff2a05c5455abc1f27d1d14167158175.tar.zst ceres-62e735a0ff2a05c5455abc1f27d1d14167158175.zip |
view: Add index handler
-rw-r--r-- | main.go | 1 | ||||
-rw-r--r-- | view/index.go | 9 |
2 files changed, 10 insertions, 0 deletions
@@ -45,6 +45,7 @@ func startServer(addr string) *http.Server { Handler(http.StripPrefix("/static/", http.FileServer(http.FS(static)))) r.HandleFunc("/recipes", view.Recipes).Methods(`GET`) r.HandleFunc("/recipe/{id:[0-9]+}", view.Recipe).Methods(`GET`) + r.HandleFunc("/", view.Index).Methods(`GET`) muxer := http.NewServeMux() muxer.Handle("/", r) diff --git a/view/index.go b/view/index.go new file mode 100644 index 0000000..8b9e73f --- /dev/null +++ b/view/index.go @@ -0,0 +1,9 @@ +package view + +import ( + "net/http" +) + +func Index(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/recipes", http.StatusSeeOther) +} |