Permalink
Browse files

prefer to match off PATH_INFO

  • Loading branch information...
1 parent 1f49c5c commit 104dd910c31b0da107b24d23cb77a5ac73bc3257 @frodwith frodwith committed Feb 16, 2010
Showing with 11 additions and 6 deletions.
  1. +2 −2 lib/Dancer/Renderer.pm
  2. +9 −4 lib/Dancer/Request.pm
View
@@ -82,7 +82,7 @@ sub get_action_response() {
Dancer::Route->run_before_filters;
my $request = Dancer::SharedData->request;
- my $path = $request->path;
+ my $path = $request->path_info;
my $method = $request->method;
my $handler = Dancer::Route->find($path, $method, $request);
@@ -91,7 +91,7 @@ sub get_action_response() {
sub get_file_response() {
my $request = Dancer::SharedData->request;
- my $path = $request->path;
+ my $path = $request->path_info;
my $static_file = path(setting('public'), $path);
return Dancer::Renderer->get_file_response_for_path($static_file);
}
View
@@ -12,7 +12,7 @@ Dancer::Request->attributes(
# query
'env', 'path', 'method',
'content_type', 'content_length',
- 'body',
+ 'body', 'path_info',
# http env
'user_agent', 'host',
@@ -70,7 +70,6 @@ sub new_for_request {
# public interface compat with CGI.pm objects (FIXME do Dancer's users really
# need that compat layer? ) Not sure...
sub request_method { method(@_) }
-sub path_info { path(@_) }
sub Vars { params(@_) }
sub input_handle { $_[0]->{env}->{'psgi.input'} }
@@ -101,8 +100,9 @@ sub params {
sub _init {
my ($self) = @_;
- $self->_build_path() unless $self->path;
- $self->_build_method() unless $self->method;
+ $self->_build_path() unless $self->path;
+ $self->_build_method() unless $self->method;
+ $self->_build_path_info() unless $self->path_info;
$self->_build_request_env();
$self->{_http_body} =
@@ -165,6 +165,11 @@ sub _build_path {
$self->{path} = $path;
}
+sub _build_path_info {
+ my ($self) = @_;
+ $self->{path_info} = $self->env->{'PATH_INFO'} || $self->path;
+}
+
sub _build_method {
my ($self) = @_;
$self->{method} = $self->env->{REQUEST_METHOD}

0 comments on commit 104dd91

Please sign in to comment.