diff options
Diffstat (limited to 'src/lazybones.lisp')
-rw-r--r-- | src/lazybones.lisp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/lazybones.lisp b/src/lazybones.lisp index ca168a5..d993f1d 100644 --- a/src/lazybones.lisp +++ b/src/lazybones.lisp @@ -191,6 +191,15 @@ app, named with the package name. If no app can be found, return NIL" (dispatch-pattern :reader endpoint-dispatch-pattern :initarg :pattern) + + (body-variables + :reader endpoint-body-variables + :initarg :body-variables + :initform nil + :documentation "A list of fields that should appear in the body of a + request that has a body. Completely optional, but used to build + client functions.") + (handler-function :reader endpoint-request-handler :initarg :function) @@ -390,6 +399,7 @@ any way to do it, hence NIL is returned." query-params (&key (auth nil) + (body-vars nil) content-type) &body body) "Defines and installs an ENDPOINT instance to the APP instance @@ -410,13 +420,19 @@ making a new one if not." (body-without-docstring (if (stringp (first body)) (rest body) body)) (real-body - (if query-params - `((lazybones:map-parameters ,query-params ,@body-without-docstring)) + (if body-vars + `((let-body ,body-vars ,@body-without-docstring)) body-without-docstring))) + + (when query-params + (setf real-body + `((map-parameters ,query-params ,@real-body)))) + `(let* ((,the-app (or (app ',appname) (make-instance 'lazybones:app :name ',appname))) (,auth-method ,auth)) + (defun ,endpoint-name ,lambda-list (declare (ignorable ,@lambda-list)) (setf (lazybones:response-header :content-type) @@ -425,8 +441,7 @@ making a new one if not." (register-endpoint ,the-app - (make-instance - 'lazybones:endpoint + (make-instance 'lazybones:endpoint :method ,method :route ,route :params ',query-params @@ -434,6 +449,7 @@ making a new one if not." :pattern ',dispatch-pattern :doc ,documentation :auth ,auth-method + :body-variables ',body-vars :function ',endpoint-name)))))) (defmacro defendpoint* (method route params options &rest body) |