Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ErrorDocument and HTTPExceptions to new site skeleton

  • Loading branch information...
commit 5b36e410a7fb8b776549e9042f42ce75277e72db 1 parent f66e8c7
@jonswar authored
View
3  Changes
@@ -4,6 +4,9 @@ Revision history for Poet
0.13 Aug 15, 2012
+* Fixes
+ - Retain response object ($m->res) when creating subrequests via $m->go and $m->visit
+
0.12 Aug 15, 2012
* Fixes
View
24 lib/Poet/t/PSGIHandler.pm
@@ -12,10 +12,7 @@ my $poet = __PACKAGE__->initialize_temp_env(
}
);
unlink( glob( $poet->comps_path("*.mc") ) );
-write_file(
- $poet->lib_path("TestApp/Foo.pm"),
- "package TestApp::Foo;\nsub bar {}\n1;\n"
-);
+write_file( $poet->lib_path("TestApp/Foo.pm"), "package TestApp::Foo;\nsub bar {}\n1;\n" );
sub mech {
my $self = shift;
@@ -38,8 +35,7 @@ sub try_psgi_comp {
my $path = $params{path} or die "must pass path";
( my $uri = $path ) =~ s/\.mc$//;
my $qs = $params{qs} || '';
- my $expect_code =
- defined( $params{expect_code} ) ? $params{expect_code} : 200;
+ my $expect_code = defined( $params{expect_code} ) ? $params{expect_code} : 200;
$self->add_comp(%params);
@@ -58,17 +54,12 @@ sub try_psgi_comp {
$mech->content_like( $expect_content, "$path - content" );
}
else {
- is(
- trim( $mech->content ),
- trim($expect_content),
- "$path - content"
- );
+ is( trim( $mech->content ), trim($expect_content), "$path - content" );
}
is( $mech->status, $expect_code, "$path - code" );
if ( my $expect_headers = $params{expect_headers} ) {
while ( my ( $hdr, $value ) = each(%$expect_headers) ) {
- cmp_deeply( $mech->res->header($hdr),
- $value, "$path - header $hdr" );
+ cmp_deeply( $mech->res->header($hdr), $value, "$path - header $hdr" );
}
}
}
@@ -100,7 +91,7 @@ sub test_error : Tests {
path => '/error.mc',
src => '% die "bleah";',
expect_code => 500,
- expect_content => qr/bleah at/,
+ expect_content => qr/bleah/,
);
}
@@ -258,9 +249,8 @@ root_dir: $expected_root_dir
sub test_misc : Tests {
my $self = shift;
$self->try_psgi_comp(
- path => '/misc.mc',
- src =>
- 'TestApp::Foo = <% TestApp::Foo->can("bar") ? "loaded" : "not loaded" %>',
+ path => '/misc.mc',
+ src => 'TestApp::Foo = <% TestApp::Foo->can("bar") ? "loaded" : "not loaded" %>',
expect_content => 'TestApp::Foo = loaded',
);
}
View
14 share/generate.skel/bin/app.psgi
@@ -13,15 +13,21 @@ builder {
# Add Plack middleware here
#
if ( $conf->is_development ) {
- enable "Plack::Middleware::StackTrace";
- enable "Plack::Middleware::Debug";
+ enable "StackTrace";
+ enable "Debug";
}
- enable "Plack::Middleware::Static",
+ enable "ErrorDocument", map { $_ => $poet->static_path("errors/$_.html") } qw(401 403 404 500);
+
+ if ( $conf->is_live ) {
+ enable "HTTPExceptions", rethrow => 0;
+ }
+
+ enable "Static",
path => qr{^/static/},
root => $poet->root_dir;
- enable "Plack::Middleware::Session",
+ enable "Session",
store => Plack::Session::Store::Cache->new(
cache => $poet->app_class('Cache')->new( namespace => 'session' ) );
View
11 share/generate.skel/static/errors/401.html
@@ -0,0 +1,11 @@
+<html>
+ <head><title>Authentication required</title></head>
+ <body>
+ <h1>Authentication required</h2>
+
+ This server could not verify that you are authorized to access the URL. You
+ either supplied the wrong credentials (e.g., bad password), or your browser
+ doesn't understand how to supply the credentials required.
+
+ </body>
+</html>
View
8 share/generate.skel/static/errors/403.html
@@ -0,0 +1,8 @@
+<html>
+ <head><title>Forbidden</title></head>
+ <body>
+ <h1>Forbidden</h2>
+
+ You don't have permission to access this URL.
+ </body>
+</html>
View
7 share/generate.skel/static/errors/404.html
@@ -0,0 +1,7 @@
+<html>
+ <head><title>Not found</title></head>
+ <body>
+ <h1>Not found</h2>
+ The requested URL was not found on this server.
+ </body>
+</html>
View
11 share/generate.skel/static/errors/500.html
@@ -0,0 +1,11 @@
+<html>
+ <head><title>Server error</title></head>
+ <body>
+ <h1>Server error</h2>
+
+ The server encountered an internal error and was
+ unable to complete your request.
+
+ </body>
+</html>
+
View
2  tidyall.ini
@@ -1,6 +1,6 @@
[PerlTidy]
argv = -noll -blbp=0 -l=100
-select = {bin,lib,t}/**/*.{pl,pm,t}
+select = {bin,lib,t}/**/*.{pl,pm,t} share/generate.skel/bin/app.psgi
[PodTidy]
select = {bin,lib}/**/*.{pl,pm,pod}
Please sign in to comment.
Something went wrong with that request. Please try again.