mascip has asked for the wisdom of the Perl Monks concerning the following question:
Hi there, I'm trying out OX.
A bit of context: until now I've used Dancer. I want to try OX and see how I like it. I have read the whole OX advent calendar 2012 and understood most of it (I'm not very familiar with Bread::Board yet).
I have a RESTful API, and I'm trying to do something a bit similar to Dancer::Plugin::REST: send something different to clients depending on the format requested. More specifically I want to send JSON back on /api/action.json, YAML on /api/action.yaml, or a prettified JSON in a HTML template on /api/action.
So far my idea is to match all those with a single route. In Dancer I would do:
/api/action.:format
And then my View object would render something that depends on the request's path: that's dead simple with OX.
My problem is that the /api/action.:format route doesn't seem to match anything. Indeed, I don't see anything similar in the Path::Router documentation, which OX is based on. Does it mean it's impossible to do what I want with OX? OX seems powerful, so I guess not.
What could be a solution to my problem?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OX and routing: how to declare something like /api/action.:format ($DEBUG++ MANIFEST)
by Anonymous Monk on Dec 08, 2013 at 14:56 UTC | |
by mascip (Pilgrim) on Dec 08, 2013 at 16:14 UTC | |
by Anonymous Monk on Dec 08, 2013 at 16:31 UTC | |
by mascip (Pilgrim) on Dec 08, 2013 at 21:18 UTC | |
by tobyink (Canon) on Dec 08, 2013 at 23:45 UTC | |
|