2 Oct 2005 04:01
More Araneida testing features: with-url-params and defurlmethod
Alan Shields <Alan-Shields <at> omrf.ouhsc.edu>
2005-10-02 02:01:33 GMT
2005-10-02 02:01:33 GMT
Hello everyone,
In a project I'm working on, it made sense to treat url parameters as
method parameters for multi-method-dispatch (like defmethod), so I wrote
defurlmethod that allows you to do that.
Example:
(defurlmethod foome (handler method request
&require bim
&key (baz "default value for baz"))
(format nil "bim: ~A, baz: ~A" bim baz))
(defmethod handle-request-response ((handler my-handler) method request)
(html-stream (request-stream request)
`(html (body (p (foome handler method request))))))
If there was at least some value for bim, it would work. Otherwise there
would be no match.
So you could do:
(defurlmethod foome (handler method request)
(format nil "Needed parameters not given!"))
to have a default.
You can do more than that, though:
(defurlmethod foome (handler method request
(Continue reading)
Marc
RSS Feed