| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::Middleware::Favicon_Simple; |
|
2
|
1
|
|
|
1
|
|
70414
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
4
|
1
|
|
|
1
|
|
482
|
use parent qw{Plack::Middleware}; |
|
|
1
|
|
|
|
|
327
|
|
|
|
1
|
|
|
|
|
4
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Plack::Middleware::Favicon_Simple - Perl Plack Middleware to provide favicon |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Plack::Builder qw{builder mount enable}; |
|
15
|
|
|
|
|
|
|
builder { |
|
16
|
|
|
|
|
|
|
enable "Plack::Middleware::Favicon_Simple"; |
|
17
|
|
|
|
|
|
|
$app; |
|
18
|
|
|
|
|
|
|
}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Browsers request /favicon.ico automatically. This Plack Middleware returns a favicon.ico file so that browsers do not get 404 HTTP codes. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 call |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Middleware wrapper method. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub call { |
|
33
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
34
|
0
|
|
|
|
|
0
|
my $env = shift; |
|
35
|
0
|
0
|
|
|
|
0
|
if ($env->{'PATH_INFO'} eq '/favicon.ico') { |
|
36
|
0
|
|
|
|
|
0
|
return [200, ['Content-Type' => 'image/x-icon'], [$self->favicon]]; |
|
37
|
|
|
|
|
|
|
} else { |
|
38
|
0
|
|
|
|
|
0
|
return $self->app->($env); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 favicon |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Sets the favicon from a binary source. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
builder { |
|
47
|
|
|
|
|
|
|
enable "Plack::Middleware::Favicon_Simple", favicon=>$binary_blob; |
|
48
|
|
|
|
|
|
|
$app; |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Default is a blank icon. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub favicon { |
|
56
|
1
|
|
|
1
|
1
|
1706
|
my $self = shift; |
|
57
|
1
|
50
|
|
|
|
52
|
$self->{'favicon'} = shift if @_; |
|
58
|
1
|
50
|
|
|
|
4
|
unless (defined $self->{'favicon'}) { |
|
59
|
|
|
|
|
|
|
#default: blank favicon.ico |
|
60
|
0
|
|
|
|
|
0
|
require MIME::Base64; |
|
61
|
0
|
|
|
|
|
0
|
$self->{'favicon'} = MIME::Base64::decode(' |
|
62
|
|
|
|
|
|
|
AAABAAEAEBACAAEAAQCwAAAAFgAAACgAAAAQAAAAIAAAAAEAAQAAAAAAgAAAAAAAAA |
|
63
|
|
|
|
|
|
|
AAAAAAAAAAAAAAAAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|
64
|
|
|
|
|
|
|
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA//8AAP//AAD//w |
|
65
|
|
|
|
|
|
|
AA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA |
|
66
|
|
|
|
|
|
|
'); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
1
|
|
|
|
|
15
|
return $self->{'favicon'}; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L, L |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Michael R. Davis |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
MIT License |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright (c) 2022 Michael R. Davis |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |