Telephone +44(0)1524 64544
Email: info@shadowcat.co.uk

Web Simple Shipped!

Web::Simple 0.001

Wed Nov 25 22:00:00 2009

Digg! submit to reddit Delicious RSS Feed Readers

So, Web::Simple has hit CPAN. It's still rough around the edges in a bunch of ways, and it's still pretty experimental, but since the contents of the distribution is currently the entire non-core-perl requirements you can always snapshot it via cp -a (which I've done for The SDL site).

What is there? Well, basic sugar and the dispatcher, which I'm really rather happy with. Here's a few examples of dispatch specifications:

GET +  /user/* + ?page~

will match a /user/* request and deliver ($self, $user_id, $page) in @_ (with $page undef if not found)

(POST|PUT) + /user/* + %:@group=&*

will match and deliver a hashref containing a scalar key for every form parameter except 'group', which will be added to the hash as an arrayref (and due to = rather than ~ will fail to match if no group is POSTed at all)

You can see a fuller explanation in the match specifications section of the POD and there are a couple of examples in the dist.

Web::Simple applications currently only run as CGI (or by supplying a URL on the command line to produce a simulated GET request). However, since it's built on Plack it should be pretty easy to add support for everything else; the key thing here was to get something working and usable - and the CGI-as-normal-deployment reminds me to keep things simple and fast.

If your code throws an error, currently the script will just die out and apache or whatever will return a normal 500 page. Again, Plack already has a prebuilt answer for us there but I've not integrated it yet.

The body parser is extremely stupid and can't handle multipart forms, so you don't get file uploads yet. And the match specifications don't (and probably won't) cover headers so if you want to try and use cookies you get to do it by hand (though your session system adding a response_filter would probably work great, and I'm going to try this when I get a minute).

But you know what? In spite of all that, this is fun to play with. And the reference documentation for the basic stuff is comprehensive and largely accurate if a little on the dry side. There's no mailing list yet because we're trying to keep this conversation, but I've set up a #web-simple IRC channel on irc.perl.org for people who're interested, and you can get the source via:

git clone git://git.shadowcat.co.uk/catagits/Web-Simple.git

and it's available for gitweb on git.shadowcat.co.uk as usual.

Have a look and come tell us what you think so far.

-- mst, out.