We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9b2775 commit 62699afCopy full SHA for 62699af
1 file changed
main.go
@@ -58,18 +58,26 @@ func main() {
58
w.Write(data)
59
})
60
61
+ // Helper to serve 404 page
62
+ serve404 := func(w http.ResponseWriter) {
63
+ data, _ := content.ReadFile("404.html")
64
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
65
+ w.WriteHeader(http.StatusNotFound)
66
+ w.Write(data)
67
+ }
68
+
69
// Serve generic error pages
70
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
71
path := strings.TrimPrefix(r.URL.Path, "/")
72
if path == "" {
73
// Default to 404
- http.Redirect(w, r, "/404", http.StatusFound)
74
+ serve404(w)
75
return
76
}
77
78
code, err := strconv.Atoi(path)
79
if err != nil || code < 100 || code > 599 {
80
81
82
83
0 commit comments