line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nephia::Plugin::ErrorPage; |
2
|
7
|
|
|
7
|
|
76493
|
use 5.008005; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
239
|
|
3
|
7
|
|
|
7
|
|
34
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
191
|
|
4
|
7
|
|
|
7
|
|
41
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
198
|
|
5
|
7
|
|
|
7
|
|
909
|
use parent 'Nephia::Plugin'; |
|
7
|
|
|
|
|
317
|
|
|
7
|
|
|
|
|
50
|
|
6
|
7
|
|
|
7
|
|
2746
|
use Nephia::Response; |
|
7
|
|
|
|
|
17385
|
|
|
7
|
|
|
|
|
151
|
|
7
|
7
|
|
|
7
|
|
5849
|
use HTTP::Status; |
|
7
|
|
|
|
|
25311
|
|
|
7
|
|
|
|
|
4547
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
6
|
|
|
6
|
0
|
120
|
my ($class, %opts) = @_; |
13
|
6
|
|
|
|
|
88
|
my $self = $class->SUPER::new(%opts); |
14
|
6
|
|
|
|
|
399
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
1
|
156155
|
sub exports { qw/ res_error res_404 / } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub res_error { |
20
|
12
|
|
|
12
|
1
|
83
|
my ($self, $context) = @_; |
21
|
|
|
|
|
|
|
sub { |
22
|
4
|
|
|
4
|
|
375
|
my ($code, $message) = @_; |
23
|
4
|
|
66
|
|
|
32
|
$message ||= HTTP::Status::status_message($code); |
24
|
4
|
|
|
|
|
54
|
my $template = $self->app->{config}{ErrorPage}{template}; |
25
|
4
|
100
|
66
|
|
|
80
|
my $content = $template && $self->app->dsl('render') ? |
26
|
|
|
|
|
|
|
$self->app->dsl('render')->($template, {code => $code, message => $message}) : |
27
|
|
|
|
|
|
|
"$code $message" |
28
|
|
|
|
|
|
|
; |
29
|
4
|
|
|
|
|
3484
|
my $res = Nephia::Response->new($code, ['Content-Type' => 'text/html; charset=UTF-8'], [$content]); |
30
|
4
|
|
|
|
|
395
|
$context->set(res => $res); |
31
|
12
|
|
|
|
|
115
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub res_404 { |
35
|
12
|
|
|
12
|
1
|
74
|
my ($self, $context) = @_; |
36
|
|
|
|
|
|
|
sub { |
37
|
2
|
|
|
2
|
|
166
|
my $template = $self->app->{config}{ErrorPage}{template}; |
38
|
2
|
100
|
66
|
|
|
35
|
my $content = $template && $self->app->dsl('render') ? |
39
|
|
|
|
|
|
|
$self->app->dsl('render')->($template, {code => 404, message => 'Not Found'}) : |
40
|
|
|
|
|
|
|
'404 Not Found' |
41
|
|
|
|
|
|
|
; |
42
|
2
|
|
|
|
|
1849
|
my $res = Nephia::Response->new(404, ['Content-Type' => 'text/html; charset=UTF-8'], [$content]); |
43
|
2
|
|
|
|
|
199
|
$context->set(res => $res); |
44
|
12
|
|
|
|
|
98
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |