File Coverage

blib/lib/Tapper/Reports/Web/Controller/Root.pm
Criterion Covered Total %
statement 23 30 76.6
branch 3 4 75.0
condition 7 9 77.7
subroutine 7 9 77.7
pod 1 2 50.0
total 41 54 75.9


line stmt bran cond sub pod time code
1             package Tapper::Reports::Web::Controller::Root;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Reports::Web::Controller::Root::VERSION = '5.0.14';
4 10     10   6755 use strict;
  10         34  
  10         378  
5 10     10   68 use warnings;
  10         34  
  10         394  
6 10     10   72 use parent 'Catalyst::Controller';
  10         26  
  10         83  
7              
8             # Sets the actions in this controller to be registered with no prefix
9             # so they function identically to actions created in MyApp.pm
10              
11             __PACKAGE__->config->{namespace} = '';
12              
13             sub index :Path :Args(0)
14             {
15 0     0   0 my ( $self, $c ) = @_;
16              
17             # the easy way, to avoid fiddling with Mason autohandlers on
18             # simple redirects
19              
20 0         0 my $body = <<EOF;
21             <html>
22             <head>
23             <meta http-equiv="refresh" content="0; URL=/tapper">
24             <meta name="description" content="Tapper"
25             <title>Tapper</title>
26             </head>
27             EOF
28 0         0 $c->response->body($body);
29 10     10   1734 }
  10         30  
  10         75  
30              
31             sub default :Path
32             {
33 0     0 0 0 my ( $self, $c ) = @_;
34 0         0 $c->response->body( 'Bummer! Page not found' );
35 0         0 $c->response->status(404);
36 10     10   127784 }
  10         29  
  10         58  
37              
38             sub end : ActionClass('RenderView') {
39              
40 18     18 1 41627 my ( $self, $or_c ) = @_;
41              
42 18 100 66     512 if (
      100        
      66        
43             !$or_c->response->body
44             && ( $or_c->res->status < 300 || $or_c->res->status > 399 )
45             && ( $or_c->res->status != 204 )
46             ) {
47 12 50       4178 if ( $or_c->req->params->{json} ) {
48 0         0 $or_c->forward('Tapper::Reports::Web::View::JSON');
49             }
50             else {
51 12         1188 $or_c->forward('Tapper::Reports::Web::View::Mason');
52             }
53             }
54              
55 18         6049 return 1;
56              
57 10     10   11308 }
  10         33  
  10         73  
58              
59             1;
60              
61             __END__
62              
63             =pod
64              
65             =encoding UTF-8
66              
67             =head1 NAME
68              
69             Tapper::Reports::Web::Controller::Root
70              
71             =head1 DESCRIPTION
72              
73             [enter your description here]
74              
75             =head1 NAME
76              
77             Tapper::Reports::Web::Controller::Root - Root Controller for Tapper::Reports::Web
78              
79             =head1 METHODS
80              
81             =head2 end
82              
83             Attempt to render a view, if needed.
84              
85             =head1 AUTHOR
86              
87             Steffen Schwigon,,,
88              
89             =head1 LICENSE
90              
91             This program is released under the following license: freebsd
92              
93             =head1 AUTHORS
94              
95             =over 4
96              
97             =item *
98              
99             AMD OSRC Tapper Team <tapper@amd64.org>
100              
101             =item *
102              
103             Tapper Team <tapper-ops@amazon.com>
104              
105             =back
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is Copyright (c) 2019 by Advanced Micro Devices, Inc..
110              
111             This is free software, licensed under:
112              
113             The (two-clause) FreeBSD License
114              
115             =cut