website/src/middlewares/assets-server.lisp

19 lines
631 B
Common Lisp
Raw Normal View History

2024-04-22 16:07:20 +09:00
(defpackage #:hp/middlewares/assets-server
2024-04-12 16:32:26 +09:00
(:use #:cl)
(:import-from #:lack.middleware.static
#:*lack-middleware-static*)
2024-04-22 16:07:20 +09:00
(:export #:*assets-server*))
(in-package #:hp/middlewares/assets-server)
2024-04-12 16:32:26 +09:00
(defun exist-public-file-p (path)
2024-04-22 05:20:14 +09:00
(let ((pathname (probe-file (concatenate 'string "assets" path))))
2024-04-12 16:32:26 +09:00
(and pathname (pathname-name pathname))))
2024-04-22 16:07:20 +09:00
(defparameter *assets-server*
2024-04-12 16:32:26 +09:00
(lambda (app)
(funcall *lack-middleware-static*
app
:path (lambda (path)
2024-04-12 17:36:28 +09:00
(and (exist-public-file-p path) path))
2024-04-22 05:20:14 +09:00
:root (asdf:system-relative-pathname :hp "assets/"))))