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) } }