Let the dancer rest!

Ok, forgive me for that easy wordplay, I haven’t take my coffee yet. I just wanted to underline the recent work Franck did. It’s just awesome, Dancer 1.170 (to be released very soon) will clearly be the “REST” release.

Most of the work has been done by Franck, so the credit for that should be his. My contribution was mainly about refactoring and suggesting some enhancement ideas, in order for the whole to fit well with the existing source code.

The main idea behind this new feature is about adding automatic serialization/deserialization support to route handlers, which makes Dancer a super-swissknife for writing API servers:

  • Whenever a route handler’s response is a ref (instead of being a string), it should be serialized with the current serializer.
  • Whenever a POST or PUT request is processed, if the content-type matches the serializer’s one, its request body should be deserialized.

This way of doing things is again fitting the philosophy of “Convention over Configuration” and does provide a real ease-of-use to the end-user. This is clearly my key-goal when I’m thinking at Dancer’s syntax, it should be context-aware as much as possible. Isn’t that Perlish afterall? :)

The serializers classes have been based on Dancer::Engine in order to let anyone who wants to implement another to be able to (just like template, logger and session engines are handled in Dancer’s core, anything is triggered by a setting).
So basically, if you feel like adding a new serializer to Dancer, you just have to implement Dancer::Serializer::Abstract, like explained previously on this blog.

Kudos to Franck and stay tuned until 1.170 is out ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes