Hi, need to build a REST API with Dancer2. Any recommendations on what plugins, if any, to use? I see Dancer2::Plugin::REST, is that the recommended one? It looks good… any experiences with it? Thanks in advance, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Hi Pedro, On Mon, 12 Oct 2015 20:16:58 +0100 Pedro Melo <melo@simplicidade.org> wrote:
Hi,
need to build a REST API with Dancer2. Any recommendations on what plugins, if any, to use?
I see Dancer2::Plugin::REST, is that the recommended one? It looks good… any experiences with it?
Yes, I originally wanted to use it, but noticed that its tests are currently failing (possibly due to a bug in Dancer2 itself): https://github.com/PerlDancer/Dancer2-Plugin-REST/pull/6 I ended up resorting to use https://metacpan.org/pod/Dancer::Plugin::REST with Dancer v1 instead for my use case. Furthermore, I was told that it's not really needed because you can encode the JSON yourself explicitly. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Humanity - Parody of Modern Life - http://shlom.in/humanity Give Yogi a rifle. Support your right to arm bears! — Unknown Source, via Nadav Har’El. Please reply to list if it's a mailing list post - http://shlom.in/reply .
Hello, On Mon, Oct 12, 2015 at 8:16 PM, Pedro Melo <melo@simplicidade.org> wrote:
Hi,
need to build a REST API with Dancer2. Any recommendations on what plugins, if any, to use?
I see Dancer2::Plugin::REST, is that the recommended one? It looks good… any experiences with it?
I always end up doing serialization "myself", instead of relying in plugins. Because many times there will be some edge cases that using the plugin will require a huge workaround. While handling the serialization yourself it's always easier to adapt. And even so I usually end up with very simple and clean applications like: sub '/users' => sub { to_json MyModel->users; }; If you prefer you can also use the "set serializer" option, to omit the to_json parts, or if you intend to have more than one serializer possible
Thanks in advance,
Best regards
-- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, On Tue, Oct 13, 2015 at 11:37 AM, Nuno Carvalho <smash@cpan.org> wrote:
On Mon, Oct 12, 2015 at 8:16 PM, Pedro Melo <melo@simplicidade.org> wrote:
need to build a REST API with Dancer2. Any recommendations on what
plugins,
if any, to use?
I see Dancer2::Plugin::REST, is that the recommended one? It looks good… any experiences with it?
I always end up doing serialization "myself", instead of relying in plugins. Because many times there will be some edge cases that using the plugin will require a huge workaround. While handling the serialization yourself it's always easier to adapt. And even so I usually end up with very simple and clean applications like:
sub '/users' => sub { to_json MyModel->users; };
If you prefer you can also use the "set serializer" option, to omit the to_json parts, or if you intend to have more than one serializer possible
Yeah… I have a base class for all my models so I'll probably take that route. Thank you all, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (3)
-
Nuno Carvalho -
Pedro Melo -
Shlomi Fish