Permalink
Browse files

[Astaire] now checks arity before calling code

This is according to what Sinatra does. We could add additional checks
at build-time, but I'm not fully committed on doing that yet. Let's see
how it works in actual usage first.
  • Loading branch information...
1 parent 12f30a7 commit 2c4149419b3065c245f0e9f6b04dfce9f51f49c4 @masak committed Dec 7, 2009
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/Astaire.pm
View
@@ -46,7 +46,14 @@ class Dispatch {
if %match<success>
&& $candidate.http_method eq $request.request_method {
my $code = $candidate.code;
- $response.write( $code(|%match<splat>) );
+ my $body;
+ if $code.arity {
+ $body = $code(|%match<splat>);
+ }
+ else {
+ $body = $code();
+ }
+ $response.write($body);
return $response;
}
}

0 comments on commit 2c41494

Please sign in to comment.