summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-11-10 09:13:30 -0300
committerEuAndreh <eu@euandre.org>2024-11-10 09:13:30 -0300
commit843708b8b0d863781d490653c352666d6a20f565 (patch)
tree7edb61461a4c627322f84d86ce3f5abc04e4cfcd
parentsrc/glaze.go: Improve spacing of struct braces (diff)
downloadglaze-843708b8b0d863781d490653c352666d6a20f565.tar.gz
glaze-843708b8b0d863781d490653c352666d6a20f565.tar.xz
src/glaze.go: Return 404 instead of 500 on missing file
-rw-r--r--src/glaze.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/glaze.go b/src/glaze.go
index c70a2ec..959cf30 100644
--- a/src/glaze.go
+++ b/src/glaze.go
@@ -140,6 +140,14 @@ func handleDirectoryTarget(info pathInfo, w http.ResponseWriter, r *http.Request
targetPath := withTrailingSlash(info.path) + r.URL.Path
newInfo, fn, err := handlerForDynPath(targetPath)
if err != nil {
+ is404 :=
+ errors.Is(err, fs.ErrNotExist ) ||
+ errors.Is(err, fs.ErrPermission)
+ if is404 {
+ httpError(w, http.StatusNotFound, err)
+ return nil
+ }
+
return err
}