Skip to content
Browse files

Simplified Application->dispatch API a little bit

  • Loading branch information...
1 parent 0324c26 commit 41432e4a7b62e58d32fecd620187e2fd145c0399 @miyagawa committed Nov 9, 2009
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/Tatsumaki/Application.pm
View
12 lib/Tatsumaki/Application.pm
@@ -40,12 +40,13 @@ sub route {
}
sub dispatch {
- my($self, $path) = @_;
+ my($self, $req) = @_;
+ my $path = $req->path;
for my $rule (@{$self->_rules}) {
if ($path =~ $rule->{path}) {
my $args = [ $1, $2, $3, $4, $5, $6, $7, $8, $9 ];
- return sub { $rule->{handler}->new(@_, args => $args) };
+ return sub { $rule->{handler}->new(@_, application => $self, request => $req, args => $args)->run };
}
}
@@ -66,13 +67,10 @@ sub compile_psgi_app {
my $env = shift;
my $req = Tatsumaki::Request->new($env);
- my $handler = $self->dispatch($req->path)
+ my $handler = $self->dispatch($req)
or return [ 404, [ 'Content-Type' => 'text/html' ], [ "404 Not Found" ] ];
- my $res = $handler->(
- application => $self,
- request => $req,
- )->run;
+ my $res = $handler->()
};
$app = Plack::Middleware::Static->wrap($app, path => sub { s/^\/static\/// }, root => $self->static_path);

0 comments on commit 41432e4

Please sign in to comment.
Something went wrong with that request. Please try again.