Skip to content

Commit

Permalink
Dispatcher - no need to add the request into the context for every app
Browse files Browse the repository at this point in the history
  • Loading branch information
veryrusty committed Sep 29, 2013
1 parent ee58580 commit 0c6e92d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/Dancer2/Core/Dispatcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ sub dispatch {
# warn "dispatching ".$env->{PATH_INFO}
# . " with ".join(", ", map { $_->name } @{$self->apps });

# initialize a context for the current request
# Once per didspatching! We should not create one context for each app or we're
# going to parse multiple time the request body/
my $context = Dancer2::Core::Context->new( env => $env );
# Initialize a context for the current request
# Once per didspatching! We should not create one context for each app or
# we're going to parse the request body multiple times
my $context = Dancer2::Core::Context->new(
env => $env,
( request => $request ) x !! $request,
);

if ( $curr_context && $curr_context->has_session ) {
$context->session( $curr_context->session );
Expand All @@ -40,10 +43,8 @@ sub dispatch {

# warn "walking through routes of ".$app->name;

# set the current app in the context
# set the current app in the context and context in the app..
$context->app($app);

$context->request($request) if defined $request;
$app->context($context);

my $http_method = lc $context->request->method;
Expand Down

0 comments on commit 0c6e92d

Please sign in to comment.