-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
38 lines (33 loc) · 1010 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package server
import (
"html/template"
"net/http"
)
type ErrorData struct {
ErrorHeader string
ErrorMessage string
}
func (s *Server) E500(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("templates/error.html", "templates/head.tmpl", "templates/navbar.tmpl")
viewData := &ErrorData{
ErrorHeader: "500",
ErrorMessage: "That's the way she goes. Sometimes she goes, sometimes she doesn't.",
}
t.Execute(w, viewData)
}
func (s *Server) E404(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("templates/error.html", "templates/head.tmpl", "templates/navbar.tmpl")
viewData := &ErrorData{
ErrorHeader: "404",
ErrorMessage: "Where's Randy's BBQ?",
}
t.Execute(w, viewData)
}
func (s *Server) E400(w http.ResponseWriter, r *http.Request) {
t, _ := template.ParseFiles("templates/error.html", "templates/head.tmpl", "templates/navbar.tmpl")
viewData := &ErrorData{
ErrorHeader: "400",
ErrorMessage: "Frig off!",
}
t.Execute(w, viewData)
}