Plugin/Headers.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 18 SCAR 6.9
CC
1
Cov
0%
build_plugin
2.0
set
2.0
BEGIN
2.0
CRAP 2.0
1 package Terse::Plugin::Headers;
2  
3 use base 'Terse::Plugin';
4  
5 sub build_plugin {
6 my ($self) = @_;
7 $self->default_headers = {
8 'Strict-Transport-Sercurity' => 'max-age=3600',
9 'X-Content-Security-Policy' => "default-src 'self'",
10 'X-Content-Type-Options' => 'nosniff',
11 'X-Download-Options' => 'noopen',
12 'X-XSS-Protection' => 1,
13 'Server' => 'guess',
14 'Cache-Control' => 'no-cache, no-store',
15 'Pragma' => 'no-cache'
16 };
17 return $self;
18 }
19  
20 sub set {
21 my ($self, $t, %headers) = @_;
22 $t->headers({
23 %{ $self->default_headers },
24 %headers
25 });
26 return $self;
27 }
28  
29 1;
30  
31 =head1 NAME
32  
33 Terse::Plugin::Headers - Terse headers
34  
35 =cut
36  
37 =head1 VERSION
38  
39 Version 0.01
40  
41 =cut
42  
43 =head1 SYNOPSIS
44  
45 package MyApp::Plugin::Headers;
46  
47 use base 'Terse::Plugin::Headers';
48  
49 1;
50  
51 package MyApp;
52  
53 use base 'Terse::App';
54  
55 sub auth {
56 my ($self, $context) = @_;
57 if ($context->req) { # second run through of the auth sub routine
58 $context->plugin('headers')->set($context, %headers);
59 }
60 }
61  
62 1;
63  
64 =cut
65  
66 =head1 LICENSE AND COPYRIGHT
67
68 L<Terse::Static>.
69
70 =cut