summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-02-15 19:43:36 +0100
committerxengineering <me@xengineering.eu>2024-02-15 19:58:08 +0100
commit62e735a0ff2a05c5455abc1f27d1d14167158175 (patch)
tree463f08b05c312f50ca636a9619d9d5047ee61f8c
parent246687318e03fb649c30c4510e264e65b25ec6da (diff)
downloadceres-62e735a0ff2a05c5455abc1f27d1d14167158175.tar
ceres-62e735a0ff2a05c5455abc1f27d1d14167158175.tar.zst
ceres-62e735a0ff2a05c5455abc1f27d1d14167158175.zip
view: Add index handler
-rw-r--r--main.go1
-rw-r--r--view/index.go9
2 files changed, 10 insertions, 0 deletions
diff --git a/main.go b/main.go
index c7a6871..2f398b3 100644
--- a/main.go
+++ b/main.go
@@ -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)
+}