diff --git a/websiteTemplate.go b/websiteTemplate.go index 3630ec0..2eaefb6 100644 --- a/websiteTemplate.go +++ b/websiteTemplate.go @@ -35,7 +35,18 @@ func main() { } +func errorHandler(w http.ResponseWriter, req *http.Request, status int) { + w.WriteHeader(status) + if status == http.StatusNotFound { + fmt.Fprint(w, "custom 404") + } +} + func blogHandler(w http.ResponseWriter, req *http.Request) { + if req.URL.Path != "/" { + errorHandler(w, req, http.StatusNotFound) + return + } posts = getNewestPosts(3) page := Page {name, sections, posts} renderTemplates(w, page)