Fix 404 error
alex wennerberg alex@alexwennerberg.com
Sun, 27 Dec 2020 21:26:56 -0800
1 files changed,
5 insertions(+),
1 deletions(-)
jump to
M
http.go
→
http.go
@@ -549,8 +549,8 @@ return
} var geminiContent string + _, err := os.Stat(path.Join(fullPath, "index.gmi")) if p == "/" || isDir { - _, err := os.Stat(path.Join(fullPath, "index.gmi")) if os.IsNotExist(err) { if p == "/gemlog" { geminiContent = generateGemfeedPage(userName)@@ -560,6 +560,10 @@ }
} else { fullPath = path.Join(fullPath, "index.gmi") } + } + if geminiContent == "" && os.IsNotExist(err) { + renderDefaultError(w, http.StatusNotFound) + return } // Dumb content negotiation _, raw := r.URL.Query()["raw"]