From 24d7487259ffb624935f774cbf17e4f7a9071fa6 Mon Sep 17 00:00:00 2001 From: Tatsuhiko Miyagawa Date: Thu, 22 Oct 2009 17:52:37 -0700 Subject: [PATCH] add ->route --- lib/Tatsumaki/Application.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Tatsumaki/Application.pm b/lib/Tatsumaki/Application.pm index fad8012..7456b6e 100644 --- a/lib/Tatsumaki/Application.pm +++ b/lib/Tatsumaki/Application.pm @@ -20,7 +20,7 @@ around BUILDARGS => sub { my @rules; while (my($path, $handler) = splice @$handlers, 0, 2) { $path = qr/^$path/ unless ref $path eq 'RegExp'; - push @rules, { path => $path, handler => $handler }; + push @rules, { path => $path, handler => $handler }}; } $class->$orig(_rules => \@rules, @_); } else { @@ -28,6 +28,12 @@ around BUILDARGS => sub { } }; +sub route { + my($self, $path, $handler) = @_; + $path = qr/^$path/ unless ref $path eq 'RegExp'; + push @{$self->{_rules}, { path => $path, handler => $handler }}; +} + sub dispatch { my($self, $path) = @_;