More Web Grant Updates - Pastebin

| No Comments | No TrackBacks

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,
    ),
 ],
)

No TrackBacks

TrackBack URL: http://blogs.gurulabs.com/cgi-bin/mt-tb.cgi/123

Leave a comment

About this Entry

This page contains a single entry by Stephen Weeks published on April 19, 2009 3:26 PM.

Tags.pm for the Perl 6 Web project was the previous entry in this blog.

Blog speed-run. is the next entry in this blog.

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