4 Mar 2006 06:05
Re: POST variables in araneida
Richard Newman <r.newman <at> reading.ac.uk>
2006-03-04 05:05:55 GMT
2006-03-04 05:05:55 GMT
James,
You might be interested in something like
(flet
((write-body-bindings (binding-specifiers body)
"Auxiliary function for with-request-params."
(loop for (var param &optional type-fun) in binding-specifiers
collecting
(list var
(if type-fun
(list type-fun (list 'body-param param body))
(list 'body-param param body))))))
(defmacro with-body-params (request binding-specifiers &body body)
"Each binding specifier is a triple, (var param &optional type-
fun).
If TYPE-FUN is not provided, CAR is used to get rid of the
wrapping
list that URL-QUERY-PARAM returns."
(let ((r-body (gensym)))
`(let ((,r-body (request-body ,request)))
(let (, <at> (write-body-bindings binding-specifiers r-body))
, <at> body)))))
which will save you typing out a load of calls to BODY-PARAM, if
you're using form-encoded bodies.
I'm sure Alan has something a lot more integrated!
Take a look in (IIRC) daemon.lisp to see how bodies are handled.
(Continue reading)
RSS Feed