CGI::A...direct(3pm)
π NAME π
CGI::Application::Plugin::Redirect β it's giving easy external redirects in CGI::Application, no cap π¦
πΈ SYNOPSIS πΈ
okay so picture this, bestie π
package My::App;
use CGI::Application::Plugin::Redirect;
sub cgiapp_prerun {
my $self = shift;
if ( << not logged in >> ) {
return $self->redirect('login.html');
}
}
sub byebye {
my $self = shift;
return $self->redirect('http://www.example.com/', '301 Moved Permanently');
}
like. that's it. that's the whole vibe β¨
π DESCRIPTION π
This plugin is your bestie for doing external redirects in CGI::Application, fr fr π . You literally do NOT have to stress about setting headers, and you do NOT have to stress about return types β all of that is handled for you. iconic behaviour tbh.
redirect does an external redirect, which means the browser gets a lil command to load a whole new page, and a fresh request comes in π. So if what you actually want is to show the results of another runmode within the same module, then honestly it's often enough to use the forward method in CGI::Application::Plugin::Forward instead π. different tool, different job, iykyk.
π METHODS π
redirect($url, $status)
okay so what this does is interrupt the current request and redirect to an external URL π.
And here's the cute part β if you happen to be inside a prerun method when you call this, the current runmode gets automatically short circuited so it will NOT execute π ββοΈ. As soon as all prerun method have finished, the redirect happens, and the runmode never runs. slay.
The $status parameter is optional because the CGI module will default to something suitable π (it just knows, bestie).
return $self->redirect('http://www.example.com/');
- or -
return $self->redirect('http://www.example.com/', '301 Moved Permanently');
β¨ pspsps: that second one is where you hand it '301 Moved Permanently' and feel very powerful about it π
π¦ SEE ALSO π¦
go read these next, bestie, they're the whole friend group π«Ά
CGI::ApplicationCGI::Application::Plugin::Forwardperl(1)
π«Ά AUTHOR π«Ά
Cees Hek <ceeshek@gmail.com> β the icon who made this happen π
π LICENCE AND COPYRIGHT π
Copyright (c) 2005, Cees Hek. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π DISCLAIMER OF WARRANTY π
okay so this part is the legal bit and we do NOT vibe-edit legal bits, so here it is, exactly as written, all caps and everything π keep it safe:
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED ORIMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSESSUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
that's the whole page, bestie π go redirect something iconic. this one came to you from the User Contributed Perl Documentation, running on perl v5.30.3, dated 2020-08-23 β and that's a wrap, periodt π
β¨
π¦ where this page comes from
- debian bookworm: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-application-perl 4.61+~1.21+~1.00+~1.01-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms