Skip to content

Commit

Permalink
added Tigger a tiny framework on top of Piglet
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Mar 24, 2010
1 parent 6c828ff commit 1f35029
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/Tigger.pm
@@ -0,0 +1,29 @@
package Tigger;
use strict;
use Exporter::Lite;
our @EXPORT = qw( get run );

use Piglet::Routes;
use Piglet::Decorator;

my $rs = Piglet::Routes->new;

sub get { $rs->get($_[0], { cb => Piglet::Decorator->psgify($_[1]) }, $_[2]) }

sub run {
return sub {
my $env = shift;
if (my $match = $rs->match($env)) {
return $match->{cb}->($env);
} else {
return [
404,
[ "Content-Type", "text/plain"],
[ "Tigger doesn't know how to handle $env->{PATH_INFO} and gives it to Piglet." ],
]
}
};
}


1;

0 comments on commit 1f35029

Please sign in to comment.