diff options
Diffstat (limited to 'lazybones.lisp')
-rw-r--r-- | lazybones.lisp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lazybones.lisp b/lazybones.lisp index c04e1e4..2b28be7 100644 --- a/lazybones.lisp +++ b/lazybones.lisp @@ -364,7 +364,20 @@ making a new one if not." `(defendpoint ,(default-app-name) ,method ,route ,options ,@body)) -;;; utilities + + +;;; ENDPOINT HANDLING UTILITIES + +(defmacro let-parameters ((&rest names) &body body) + "NAMES is a list of symbols. Binds the names to the value of the +request parameters whose keys compare string-equal to the symbol-name +of each NAME, or NIL if there is no such parameter." + (let ((params (gensym))) + `(let ((,params (lazybones:request-parameters))) + (let ,(loop for name in names + for string-name = (symbol-name name) + collect `(,name (cdr (assoc ,string-name ,params :test #'string-equal)))) + ,@body)))) (defun http-ok (content) "Content should be a string, a byte-vector, or a pathname to a local |