[Dancer-users] one route, different actions based on context

Puneet Kishor punk.kish at gmail.com
Fri Dec 24 20:17:09 CET 2010


I am fairly certain I saw mention of this in the docs, but I can't find 
it now, so here goes --

The route `get '/all'` is invoked from the browser by going to 
http://application/foo/all. This causes a template to be rendered with 
all the "chrome" of the application, the buttons, the forms, the logos, 
bylines, etc. The crap that Edward Tufte refers to as "administrivia." 
This template is appropriately filled with data from a query for "all" 
foo widgets from the data store.

Well, I also want `get '/all'` to callable from the command line. So, if 
the user types

$ curl http://application/foo/all

a json stream of all the foo widgets is returned.

How do I accomplish the above? That is, have a single route called `get 
'/all'` and yet be able to call it either from a browser or from a 
command line but with different "stuff" returned? Seems like the ajax 
plugin is not the solution? or is it? I can't make out from its 
documentation.




-- 
Puneet Kishor


More information about the Dancer-users mailing list