April 2009 Archives

I’ve still been working on the Web libraries for Perl 6.

In the past week, I’ve improved my Tags library to handle more common cases and be easier to use, I migrated HTTP::Daemon to use Parrot sockets instead of exec-ing socat, and I wrote a basic pastebin: http://github.com/masak/web/blob/c84c4c1892463459e406958db8f9232e7b7bf5d1/bin/kopipasta.pl.

You might be able to see a running instance here: http://pleasedieinafire.net:2080/. That host has poor connectivity lately, though.

I’ve also played a bit with some ideas related to dispatch. Here’s an example I got working on the plane home from Boston:

use LolDispatch;
use HTTP::Daemon;
sub item($request, $match) is handler(/^\/item\/(\d+)/) {
    say 'dispatched to item';
    say $match.perl;
}
my $request = HTTP::Request.new(
    req_url => HTTP::url.new(path => '/item/12345'),
    headers => HTTP::Headers.new( header_values => { 'Host' => 'localhost' }),
    req_method => 'GET',
);
dispatch($request);

Here’s the output of that example:

dispatched to item
Match.new(
 # WARNING: this is not working perl code
 # and for debugging purposes only
 ast  => "/item/12345",
 text => "/item/12345",
 from => 0,
 to   => 11,
 positional => [
  Match.new(
     ast  => "12345",
     text => "12345",
     from => 6,
     to   => 11,
    ),
 ],
)

About this Archive

This page is an archive of entries from April 2009 listed from newest to oldest.

March 2009 is the previous archive.

May 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en