Dancer Goes Megasplat
No, Santa Claus' sleigh just didn't have the mother of all reindeer-benders. This article is rather about the little-known but very useful feature of Dancer known as the megasplat.
So, what's the megasplat? Well,
Dancer, being heavily influenced by Ruby's Sinatra, adopted its splat placeholder, which allows to capture elements of a route:
That route will match /wishlist/timmy, and /wishlist/sandy, and the wishlist of every other child in the world, but what if we want to match several path elements? That's where we go mega:
With that, we can hit /giddy_up/Prancer/Dancer/Vixen/Cupid and get back:
Now, Prancer! To the top of the porch, Dancer! To the top of the wall, Vixen! On, Cupid!
Besides that, the megasplat can also be used to mimick Catalyst's chaining behavior:
Which will give Santa a nice little basic web service for his Nice & Naughty book keeping:
$ curl http://api.toydb.np/child/rjbs/nice nicely done $ curl http://api.toydb.np/child/yanick/naughty tsk tsk $ curl -X PUT http://api.toydb.np/child/rjbs/gift/pony noted $ curl -X PUT http://api.toydb.np/child/yanick/gift/pony noted $ curl http://api.toydb.np/child/yanick/gift coal $ curl http://api.toydb.np/child/rjbs/gift pony