-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
39 lines (33 loc) · 688 Bytes
/
utils.go
File metadata and controls
39 lines (33 loc) · 688 Bytes
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
39
package main
import (
"net/http"
)
type Error struct {
Err string
Desc string
}
var error404 = Error{
Err: "Error: 404",
Desc: "Not Found",
}
var error400 = Error{
Err: "Error: 400",
Desc: "Bad Request",
}
var error500 = Error{
Err: "Error: 500",
Desc: "Internal Server Error",
}
func ThrowError(statuscode string, w http.ResponseWriter, r *http.Request) {
switch statuscode {
case "400":
w.WriteHeader(http.StatusBadRequest)
executeTemp(w, "error.html", error400)
case "404":
w.WriteHeader(http.StatusNotFound)
executeTemp(w, "error.html", error404)
case "500":
w.WriteHeader(http.StatusInternalServerError)
executeTemp(w, "error.html", error500)
}
}