Permalink
Browse files

added Tigger a tiny framework on top of Piglet

  • Loading branch information...
1 parent 6c828ff commit 1f350294d31063b2cc6ccf4aafd744783eac3630 @miyagawa committed Mar 24, 2010
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/Tigger.pm
View
@@ -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.