-
-
Save PuercoPop/fb40d1cb8025272c3ba2437e71f26a3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro define-regexp-route (name (url-regexp &rest capture-names) &body body) | |
(multiple-value-bind (body declarations documentation) | |
(parse-body body :documentation t) | |
`(progn | |
(defun ,name () | |
,@(when documentation | |
(list documentation)) | |
,@declarations | |
(when *debug* | |
(format *trace-output* "=== Calling ~A Handler ===" ',name)) | |
(match (script-name *request*) | |
((ppcre ,url-regexp ,@capture-names) | |
,@body))) | |
(push (create-regex-dispatcher ,url-regexp ',name) | |
*dispatch-table*)))) | |
(define-regexp-route display-entry ("^/entry/(.*?)/$" entry-title) | |
"Display the contents of the ENTRY." | |
(when-let ((entry (find-entry-by-title entry-title))) | |
(show-entry entry))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment