File Coverage

blib/lib/Catalyst/Plugin/DefaultEnd.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::DefaultEnd;
2              
3 1     1   28430 use base qw/Catalyst::Controller/;
  1         2  
  1         812  
4              
5             use strict;
6             our $VERSION = '0.08';
7              
8             =head1 NAME
9              
10             Catalyst::Plugin::DefaultEnd - DEPRECATED Sensible default end action.
11              
12             =head1 SYNOPSIS
13              
14             use Catalyst qw/-Debug DefaultEnd/;
15              
16             =head1 WARNING
17              
18             This module is deprecated, and B<should not be used in new applications>.
19              
20             Please use L<Catalyst::Action::RenderView> instead. It is preserved here for
21             backwards compatibility reasons.
22              
23             =head1 DESCRIPTION
24              
25             This action implements a sensible default end action, which will forward
26             to the first available view, unless status is set to 3xx, or there is a
27             response body. It also allows you to pass dump_info=1 to the url in order
28             to force a debug screen, while in debug mode.
29              
30             If you have more than 1 view, you can specify which one to use with the
31             'view' config setting.
32              
33             =head1 METHODS
34              
35             =over 4
36              
37             =item end
38              
39             The default end action, you can override this as required in your application
40             class, normal inheritance applies.
41              
42             =cut
43              
44             sub end : Private {
45             my ( $self, $c ) = @_;
46             die "forced debug" if $c->debug && $c->req->params->{dump_info};
47             return 1 if $c->req->method eq 'HEAD';
48             return 1 if scalar @{ $c->error } && !$c->stash->{template};
49             return 1 if $c->response->status =~ /^(?:401|204|3\d\d)$/;
50             unless ( $c->response->content_type ) {
51             $c->response->content_type('text/html; charset=utf-8');
52             }
53             return 1 if $c->response->body;
54             return $c->forward( $c->config->{view} ) if $c->config->{view};
55             my ($comp) = $c->comp( '^' . ref($c) . '::(V|View)::' );
56             $c->forward( ref $comp );
57             }
58              
59             =back
60              
61             =head1 AUTHOR
62              
63             Marcus Ramberg <marcus@thefeed.no>
64              
65             =head1 COPYRIGHT
66              
67             Copyright (c) 2005 - 2009
68             the Catalyst::Plugin::DefaultEnd L</AUTHOR>
69             as listed above.
70              
71             =head1 LICENSE
72              
73             This library is free software . You can redistribute it and/or modify it under
74             the same terms as perl itself.
75              
76             =cut
77              
78             1;