aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-09 00:57:31 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-15 01:43:12 +0100
commit9d5bec0b6deb5d7a9efd5df907c869b9f6c8043f (patch)
tree2a428e6c365f961897cffb56e3f524777f3c41ec
parentAdd alt make-watch for static in existing TMUX sessions. (diff)
downloadcalp-9d5bec0b6deb5d7a9efd5df907c869b9f6c8043f.tar.gz
calp-9d5bec0b6deb5d7a9efd5df907c869b9f6c8043f.tar.xz
Calp server now 404s on missing file on disk.
-rw-r--r--module/calp/server/routes.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm
index 3fa9bc4d..843eb01c 100644
--- a/module/calp/server/routes.scm
+++ b/module/calp/server/routes.scm
@@ -433,10 +433,18 @@
[(js) "javascript"]
[else ext]))
- (return
- `((content-type ,(string->symbol (string-append "text/" mime))))
- (call-with-input-file (string-append "static/" * "." ext)
- read-string)))
+ (catch 'system-error
+ (lambda ()
+ (return
+ `((content-type ,(string->symbol (string-append "text/" mime))))
+ (call-with-input-file (string-append "static/" * "." ext)
+ read-string)))
+ (lambda (err proc fmt fmt-args data)
+ (warning (format #f "404|500: ~?" fmt fmt-args))
+ (if (and (not (null? data)) (= 2 (car data)))
+ (return (build-response code: 404)
+ (format #f "~?" fmt fmt-args))
+ (scm-error err proc fmt fmt-args data)))))
(GET "/static/:*{.*}" (*)
(return