The dawn of the micro web frameworks, introducing dancer

, web-dev, dancer

Turns out micro-frameworks are really in these days, there is:

I’ve been using Dancer pretty often, I recently built with it.

So this is what a simple dancer app looks like:

Save the following in

Then in your command line:

$ perl &
$ curl http://localhost:3000/
Hello world!

If you know enough web development you probably get it. This line get '/' => sub {} registers the url : / with a subroutine, or more correctly a coderef (a reference to a subroutine)

That means the homepage (like will show “Hello world” in the browser. (In perl the last statement in sub will be the return value)

Now lets get to something more complicated. Need a webservice, just use this plugin Dancer::Plugin::REST. This sample is copied straight from the POD for that plugin :P

Note if you individually needed to add a route that returned json you could always use to to_json method from within a sub.

Need to do github authentication in your application? Simple use this plugin Dancer::Plugin::Auth::Github, yes I wrote this one! :

Yes there is a plugin to do authentication for twitter, and more plugins to do other cool stuff too.

So what are you waiting for? Go and dance your way into an awesome web application.

Share on Twitter, Facebook, Google+
Prev Next