Treat package names as string

This commit is contained in:
paku 2024-03-11 13:15:54 +09:00
parent 19d3d521f2
commit 68c3e0494d
3 changed files with 7 additions and 13 deletions

1
qlfile
View file

@ -1,4 +1,3 @@
ql ningle ql ningle
ql cl-ppcre ql cl-ppcre
ql rove ql rove
ql alexandria

View file

@ -14,7 +14,3 @@
(:class qlot/source/ql:source-ql (:class qlot/source/ql:source-ql
:initargs (:%version :latest) :initargs (:%version :latest)
:version "ql-2023-10-21")) :version "ql-2023-10-21"))
("alexandria" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-10-21"))

View file

@ -1,7 +1,6 @@
(uiop:define-package :ningle-fbr (uiop:define-package :ningle-fbr
(:nicknames #:ningle-fbr/main) (:nicknames #:ningle-fbr/main)
(:use #:cl) (:use #:cl)
(:local-nicknames (#:alx #:alexandria))
(:local-nicknames (#:re #:cl-ppcre)) (:local-nicknames (#:re #:cl-ppcre))
(:local-nicknames (#:ng #:ningle)) (:local-nicknames (#:ng #:ningle))
(:export #:enable-file-based-routing)) (:export #:enable-file-based-routing))
@ -28,11 +27,10 @@
""))) "")))
(defun pathname->package (pathname system-path-namestring system-prefix) (defun pathname->package (pathname system-path-namestring system-prefix)
(alx:make-keyword
(string-upcase (string-upcase
(re:regex-replace system-path-namestring (re:regex-replace system-path-namestring
(remove-file-type (namestring pathname)) (remove-file-type (namestring pathname))
system-prefix)))) system-prefix)))
(defun dir->pathnames (dir) (defun dir->pathnames (dir)
(directory (concatenate 'string (directory (concatenate 'string
@ -52,7 +50,7 @@
(dir->pathnames dir)))) (dir->pathnames dir))))
(defparameter *http-request-methods* (defparameter *http-request-methods*
'(:GET :HEAD :POST :PUT :DELETE :CONNECT :OPTIONS :PATCH)) '(:GET :POST :PUT :DELETE :HEAD :CONNECT :OPTIONS :PATCH))
(defun enable-file-based-routing (app &key directory system) (defun enable-file-based-routing (app &key directory system)
(loop (loop
@ -60,6 +58,7 @@
:do (ql:quickload pkg) :do (ql:quickload pkg)
(loop (loop
:for method :in *http-request-methods* :for method :in *http-request-methods*
:do (let ((handler (find-symbol (string (alx:symbolicate 'on- method)) pkg))) :do (let ((handler (find-symbol (concatenate 'string "ON-" (string method))
pkg)))
(when handler (when handler
(setf (ng:route app url :method method) handler)))))) (setf (ng:route app url :method method) handler))))))