forked from ohayo-jacob/takunomi-blog
added errorhandling
This commit is contained in:
parent
80e925baf5
commit
cccbc9f537
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user