tag:blogger.com,1999:blog-11685859.post685339831673222615..comments2023-12-18T15:37:37.183+05:30Comments on Sandeep Shetty's Blog: Describing your web application using Swx (take 1)Sandeep Shettyhttp://www.blogger.com/profile/05858379451002808518noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-11685859.post-5109148190966274712009-06-28T03:27:08.199+05:302009-06-28T03:27:08.199+05:30> Why do you do {[id]}, why not just [id].
Its...> Why do you do {[id]}, why not just [id].<br /><br />Its actually [{id}]. The braces are needed to capture the variable id and the square brackets make it optional.Sandeep Shettyhttps://www.blogger.com/profile/05858379451002808518noreply@blogger.comtag:blogger.com,1999:blog-11685859.post-34261153557661467392009-06-27T21:46:04.632+05:302009-06-27T21:46:04.632+05:30Magnificent!
This makes routes quite easy to spec...Magnificent!<br /><br />This makes routes quite easy to specify.<br /><br />Why do you do {[id]}, why not just [id].<br /><br />A portion of your dsl here is parsed out of a string. I usually tend towards keeping my dsls as far as possible in code.<br /><br />My lisp way of doing it would be:<br /><br />(route POST /{handler})<br />(route /{handler}/[id])<br />(route GET {handler}.example.com/foobar)<br /><br />It's almost the same in many ways.<br /><br />This would be nice too:<br /><br />(route GET {handler}.example.com/person/[id]/{visiting-card})<br /><br />in which two handlers (handler and visiting-card) get called.<br /><br />Or even:<br /><br />(route GET<br /> #'(lambda (name) (format t "You are at ~a!" name))<br /> .example.com/person/<br /> #'(lambda (id) (using-person id (format t "hello ~a~%" name))))<br /><br />in which the handlers is defined inline. The url that hits this route of course is stuff.example.com/person/10<br /><br />How about:<br /><br />(routes<br /> * POST / {handler}<br /> * / {handler} / [id]<br /> * GET {handler} .example.com /foobar<br /> * GET {handler} .example.com /person/ [id]<br /> * GET {handler} .example.com /person/ [id] / {visiting-card}<br /> * GET<br /> #'(lambda (name) (format t "You are at ~a!" name))<br /> .example.com/person/<br /> #'(lambda (id) (using-person id (format t "hello ~a~%" name))))<br /><br />I think lisp can handle that. It's very much in the fashion of the powerful loop macro (see http://cl-cookbook.sourceforge.net/loop.html).Anonymousnoreply@blogger.com