GoBlog/errors.go

22 lines
356 B
Go
Raw Normal View History

package main
import (
"fmt"
"net/http"
)
type errorData struct {
2020-09-21 14:12:17 +00:00
Title string
Message string
}
2020-09-21 14:12:17 +00:00
func serve404(w http.ResponseWriter, r *http.Request) {
2020-10-12 16:47:23 +00:00
render(w, templateError, &renderData{
Data: &errorData{
Title: "404 Not Found",
Message: fmt.Sprintf("`%s` was not found", r.RequestURI),
},
})
w.WriteHeader(http.StatusNotFound)
}