summaryrefslogtreecommitdiff
path: root/website.go
diff options
context:
space:
mode:
authorKyren223 <contact@kyren.codes>2026-10-06 20:46:31 +0300
committerKyren223 <contact@kyren.codes>2026-10-06 20:46:31 +0300
commitba1be9573ef20d6424ae987257a1c727c47d4b53 (patch)
treee59ef56f19142215070d0516a9b3a110d15557b6 /website.go
parentea056b6e080669ba4b6f16c2757b4e2e88ea0553 (diff)
Initial setup for website rewrite
Diffstat (limited to 'website.go')
-rw-r--r--website.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/website.go b/website.go
new file mode 100644
index 0000000..d1cf44d
--- /dev/null
+++ b/website.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "fmt"
+ "net/http"
+)
+
+func main() {
+ fmt.Println("foo")
+
+ mux := http.NewServeMux()
+
+ fileServer := http.FileServer(http.Dir("./public"))
+ mux.Handle("GET /public/", http.StripPrefix("/public/", fileServer))
+
+ mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
+ HomePage().Render(r.Context(), w)
+ })
+
+ mux.HandleFunc("GET /about", func(w http.ResponseWriter, r *http.Request) {
+ AboutPage().Render(r.Context(), w)
+ })
+
+ mux.HandleFunc("GET /items", func(w http.ResponseWriter, r *http.Request) {
+ data := []Item{
+ {Name: "Foo", Active: true},
+ {Name: "Bar", Active: true},
+ {Name: "Baz", Active: false},
+ }
+ ItemsPage(data).Render(r.Context(), w)
+ })
+
+ fmt.Println("Server running at http://localhost:8080")
+ if err := http.ListenAndServe(":8080", mux); err != nil {
+ panic(err)
+ }
+}