1package Catalyst::Plugin::DefaultEnd; 2 3use base qw/Catalyst::Controller/; 4 5use strict; 6our $VERSION = '0.08'; 7 8=head1 NAME 9 10Catalyst::Plugin::DefaultEnd - DEPRECATED Sensible default end action. 11 12=head1 SYNOPSIS 13 14 use Catalyst qw/-Debug DefaultEnd/; 15 16=head1 WARNING 17 18This module is deprecated, and B<should not be used in new applications>. 19 20Please use L<Catalyst::Action::RenderView> instead. It is preserved here for 21backwards compatibility reasons. 22 23=head1 DESCRIPTION 24 25This action implements a sensible default end action, which will forward 26to the first available view, unless status is set to 3xx, or there is a 27response body. It also allows you to pass dump_info=1 to the url in order 28to force a debug screen, while in debug mode. 29 30If 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 39The default end action, you can override this as required in your application 40class, normal inheritance applies. 41 42=cut 43 44sub 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 63Marcus Ramberg <marcus@thefeed.no> 64 65=head1 COPYRIGHT 66 67Copyright (c) 2005 - 2009 68the Catalyst::Plugin::DefaultEnd L</AUTHOR> 69as listed above. 70 71=head1 LICENSE 72 73This library is free software . You can redistribute it and/or modify it under 74the same terms as perl itself. 75 76=cut 77 781; 79