[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] "catch-all" in CGI::Application::Dispatch




Jesse Erlbaum wrote:
Like having one more name value pair passed to the dispatch() method like:
    no_match => { '/myapp/notfound/'},
which will be used if nothing else matches.


There is a facility like this built directly into CGI::Application:


THE RUN MODE OF LAST RESORT: "AUTOLOAD"

If CGI::Application is asked to go to a run mode which doesn't exist it
will usually croak() with errors. If this is not your desired behavior,
it is possible to catch this exception by implementing a run mode with
the reserved name "AUTOLOAD":

  $self->run_modes(
        "AUTOLOAD" => \&catch_my_exception
  );



I'm using the "AUTOLOAD" already. The "AUTOLOAD" is fine for non existing runmodes. But I think this is not enough for what I'm writing about: no entries at all matching the in dispatch table of CGI::Application::Dispatch. CGI::Application::Dispatch will not match any entry in the table for a given request, so it will not instantiate any subclass of CGI::Application (in which the "AUTOLOAD" might be defined).
The "AUTOLOAD" is ok to handle requests like:
   /myapp/welcome/start
where there is no 'start' runmode in a Class named "Welcome" (which is a CGI::Application subclass), but I'm taking about requests like:
   /myapp/foo/start
where the Class "Foo" does not exist at all.

Regards,
Giannis




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.