package page import ( "log" "net/http" "path/filepath" ) func SetupHandlers() { http.Handle("/static/", StaticHandler()) http.HandleFunc("/", PageHandler) } func PageHandler(w http.ResponseWriter, r *http.Request) { u := r.URL.Path if u == "/" { u = "/index" } u = filepath.Join(".", u) log.Println(u) p := &Page{Name: u} err := p.Render(w) if err != nil { log.Println(err) http.Error(w, "Internal server error", 500) return } } func StaticHandler() (h http.Handler) { return http.StripPrefix("/static/", http.FileServer(http.Dir("static"))) }