CGI::Application::Dispatch::BuildURI - Build URI including full path_info in CGI::Application::Dispatch
# in your CGI::Application module use CGI::Application::Dispatch::BuildURI; sub some_rm { my $self = shift; my $location = $self->build_uri( module => 'some_module', rm => 'some_rm', query_string => 'key=value', ); # $location is http://www.example.com/example.cgi/some_module/some_rm?key=value } sub cgiapp_prerun { my $self = shift; $self->move_uri(); }
This module provides a easier way to treat relative path in template files when using CGI::Application::Dispatch.
When we use CGI::Application::Dispatch, we get follow URIs and URIs return same page.
1. http://www.example.com/example.cgi 2. http://www.example.com/example.cgi/some_module 3. http://www.example.com/example.cgi/some_module/some_rm
If we write relative path in template files, we are confused to treat relative path. For example, this link is work on URI 1 but don't work on URI 2 and 3.
<a href="./example.cgi/another_module/another_rm">another page</a>
This module provides build_uri() method. This method is create URI that including full path_info, like URI 3.
build_uri() method receive three arguments and generate URI that including full path_info. Three arguments are 'module', 'rm', 'query_string'. 'module' is your package name. 'module' is used lower characters all of the time. 'rm' is your run_mode. 'query_string' is $ENV{QUERY_STRING}. If these arguments does not set, build_uri() automatically fill empty argument by default setting value.
move_uri() method work two things, generate URI by build_uri and redirect to that URI. Redirection is provided by CGI::Application::Plugin::Redirect. move_uri() is for laziness. This is useful in cgiapp_prerun() method.
cgiapp_prerun { my $self = shift; $self->move_uri(); }
You get full-path_info-including URI anytime. If you use this method in your cgiapp's base class, you only call move_uri one time on your base class's cgiapp_prerun() method.
CGI::Application, CGI::Application::Dispatch, CGI::Application::Plugin::Redirect
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
Kensuke Kaneko <kyanny@gmail.com>
Copyright (C) 2005 by Kensuke Kaneko. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install CGI::Application::Dispatch::BuildURI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Dispatch::BuildURI
CPAN shell
perl -MCPAN -e shell install CGI::Application::Dispatch::BuildURI
For more information on module installation, please visit the detailed CPAN module installation guide.