1Plack::Middleware::ErroUrsDeorcuCmoennttr(i3b)uted PerlPDloaccukm:e:nMtiadtdiloenware::ErrorDocument(3)
2
3
4
6 Plack::Middleware::ErrorDocument - Set Error Document based on HTTP
7 status code
8
10 # in app.psgi
11 use Plack::Builder;
12
13 builder {
14 enable "Plack::Middleware::ErrorDocument",
15 500 => '/uri/errors/500.html', 404 => '/uri/errors/404.html',
16 subrequest => 1;
17 $app;
18 };
19
21 Plack::Middleware::ErrorDocument allows you to customize error screen
22 by setting paths (file system path or URI path) of error pages per
23 status code.
24
26 subrequest
27 A boolean flag to serve error pages using a new GET sub request.
28 Defaults to false, which means it serves error pages using file
29 system path.
30
31 builder {
32 enable "Plack::Middleware::ErrorDocument",
33 502 => '/home/www/htdocs/errors/maint.html';
34 enable "Plack::Middleware::ErrorDocument",
35 404 => '/static/404.html', 403 => '/static/403.html', subrequest => 1;
36 $app;
37 };
38
39 This configuration serves 502 error pages from file system directly
40 assuming that's when you probably maintain database etc. but serves
41 404 and 403 pages using a sub request so your application can do
42 some logic there like logging or doing suggestions.
43
44 When using a subrequest, the subrequest should return a regular
45 '200' response.
46
48 Tatsuhiko Miyagawa
49
51perl v5.34.0 2022-01-21Plack::Middleware::ErrorDocument(3)