filter_response { $self->render_html($_[1]) },
},
sub (GET + /) {
- $self->redispatch('/index.html')
+ redispatch_to '/index.html';
},
sub (GET + /index) {
$self->post_list
*{"${app_package}::filter_response"} = sub (&) {
$app_package->_construct_response_filter($_[0]);
};
+ *{"${app_package}::redispatch_to"} = sub {
+ $app_package->_construct_redispatch($_[0]);
+ };
*{"${app_package}::default_config"} = sub {
my @defaults = @_;
*{"${app_package}::_default_config"} = sub { @defaults };
and $_[1]->isa('Web::Simple::ResponseFilter');
}
+sub _construct_redispatch {
+ bless(\$_[1], 'Web::Simple::Redispatch');
+}
+
+sub _is_redispatch {
+ return unless
+ "$_[1]" =~ /\w+=[A-Z]/
+ and $_[1]->isa('Web::Simple::Redispatch');
+ return ${$_[1]};
+}
+
sub _dispatch_parser {
require Web::Simple::DispatchParser;
return Web::Simple::DispatchParser->new;
$result,
$self->_run_dispatch_for($new_env, \@disp)
);
+ } elsif (my $path = $self->_is_redispatch($result)) {
+ $new_env->{PATH_INFO} = $path;
+ return $self->_run_dispatch_for($new_env, $dispatchables);
}
return $result;
}
my $res;
-$res = run_request(GET 'http://localhost/index.html');
+warn run_request(GET 'http://localhost/index.html')->as_string;
-warn $res->as_string;
+warn run_request(GET 'http://localhost/')->as_string;
warn run_request(GET 'http://localhost/One-Post.html')->as_string;