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?


In reply to OX and routing: how to declare something like /api/action.:format by mascip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.