website/src/app.lisp

38 lines
1 KiB
Common Lisp
Raw Normal View History

2024-02-13 20:34:31 +09:00
(uiop:define-package #:hp/app
2024-02-02 01:07:19 +09:00
(:use #:cl)
2024-02-13 20:34:31 +09:00
(:local-nicknames (#:jg #:jingle))
2024-02-14 01:18:20 +09:00
(:local-nicknames (#:fbr #:ningle-fbr))
2024-02-02 01:07:19 +09:00
(:import-from #:lack)
2024-02-14 00:15:37 +09:00
(:export #:*app*
#:update-routes))
2024-02-02 01:07:19 +09:00
(in-package #:hp/app)
2024-02-14 00:15:37 +09:00
(defparameter *raw-app* (jg:make-app))
(defun update-routes ()
2024-02-14 01:18:20 +09:00
(fbr:enable-file-based-routing *raw-app*
:dir "src/routes"
:system "hp"
:system-pathname "src"))
2024-02-14 00:15:37 +09:00
(update-routes)
2024-02-24 18:18:24 +09:00
(defun exist-public-file-p (path)
(and (not (string= path "/"))
(let ((pathname (probe-file (concatenate 'string "public" path))))
(and pathname
(pathname-name pathname)))))
2024-02-02 01:07:19 +09:00
(defparameter *app*
2024-02-24 11:44:10 +09:00
(lack:builder :accesslog
(:static
2024-02-24 18:18:24 +09:00
:path (lambda (path)
(if (exist-public-file-p path)
path
nil))
2024-02-24 11:44:10 +09:00
:root (asdf:system-relative-pathname :hp "public/"))
2024-02-14 00:15:37 +09:00
*raw-app*))
2024-02-02 01:07:19 +09:00
; for clackup cmd
*app*