Hello, everyone! I made a module named CGI::Application::Dispatch::BuildURI. This module resolve a relative URI path's problem when writing template files.
When I use CGI::Application::Dispatch, I often confused by relative URI path difference. For example, following two URI call same module and same runmode, but Browser follow different link whether URI including PATH_INFO or not. http://www.example.com/example.cgi http://www.example.com/example.cgi/start/do_start So, I provide build_uri() method, this method generates URI including complete PATH_INFO. This build_uri() method is used on each runmode method. use CGI::Application::Dispatch::BuildURI; sub do_start { my $self = shift; my $location = $self->build_uri( module => 'start', rm => 'do_start', query_string => 'key=value', ); # $location is 'http://www.example.com/example.cgi/start/do_start?key=value' } You may feel a pain if you must call any redirection. And, if you must call build_uri() all runmode, it's a frighening thought. So, I provide move_uri() method.This method is useful for using on cgiapp_prerun. sub cgiapp_prerun { my $self = shift; $self->move_uri(); # automatically redirect URI } If you access abbreviated URI, these method move URI to complete URI. You will not confuse by template's relative path. If 'module' parameter is not assigned, build_uri() set default module name that is assigned as DEFAULT => 'Start' when CGI::Application::Dispatch instance is created. As in the case of 'module', when rm parameter is not assigned, build_uri() set start_mode as default value, also move_uri(). I would upload this module to CPAN, but I am worried about two reasons. First, whether module name is correct or not. If I use common name, I occupy valuable namespace. This module is my first work, so I don't know a custom. Second, whether my test is enough or not. I read 'Perl medic' and perldoc Test::Tutorial, but this is my first test code, I am worried about my test is not enough. I upload tarball which made by 'make dist' and passed 'make test' on my Perl(v5.8.6). http://www.kyanny.net/lib/CGI-Application-Dispatch-BuildURI-0.01.tar.gz Please tell me your opinion! Regards -- Kensuke Kaneko <[EMAIL PROTECTED]> --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
