CGI::A...direct(3pm)

πŸ“¦
version 4.61+~1.21+~1.00+~1.01 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::Application
  • CGI::Application::Plugin::Forward
  • perl(1)

🫢 AUTHOR 🫢

Cees Hek <ceeshek@gmail.com> β€” the icon who made this happen πŸ‘‘


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