Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
First off, big kudos and ++ to you for actually implementing a REST plugin! I know there's been talk on and off about this, both on the cgiapp mailinglist and in #cgiapp, and it's very exciting to finally have something real.

I do have the feeling that the REST_route setup calls are a bit verbose. Would it be possible to come up with a terser interface?

Maybe something like this:

$self->REST_route( widgets => { GET => { MEDIA_TYPES => [...], FUNCTION => [...] }, POST => { ... }, }, some_other_runmode => { GET => { ... }, POST => { ... }, }, );
That avoids typing out the obvious for every single runmode/request_method combination.

Another idea is to configure the REST details with attributes on the actual functions. That might look like this:

# nothing in setup() sub get_widget : REST( GET => widgets, TYPES => [ 'application/xhtml+xml', 'text/ht +ml', 'text/plain' ], PARAMS => [ 'product_number' ] ) { # implementation }
That might be a bit heavy though, and it may not be too practical. But the obvious benefit is that you keep the REST details close to the function handling the request, and there is minimal redundancy.

Anyway, this is in no way meant to detract from the excellent work you did here. These ideas just popped up on first reading, and I didn't think them through. Take them for what they're worth :-)


In reply to Re: RFC: CGI::Application::Plugin::REST by rhesa
in thread RFC: CGI::Application::Plugin::REST by jaldhar

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (7)
    As of 2014-09-22 21:17 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (202 votes), past polls