[cgiapp] Re: CGI::Application::Server enhancements (for Dispatch)

Mark Stosberg mark at summersault.com
Wed Oct 31 20:09:45 EDT 2007


>
> I didn't notice CA::Dispatch::Server when I was doing some poking at some
> code the other day so instead I patched CGI::Application::Server to handle
> ::Dispatch modules.
> 
> I think this was a good mistake: CADS doesn't really strike me as being as
> good
> a design as CAServer.  In CADS, you say:
>   
>   * here is a doc root
>   * here is a Dispatch class
>   * if you can't find static content, try Dispatch
> 
> With CAS, you say:
> 
>   * here is docroot
>   * here is a mapping of paths to CA classes
>   * if it isn't mapped to CA, try looking in the docroot
> 
> So, there's already some ability to point to multiple CA classes with CAS.
> With my patch (which will shortly be available in a new release of CAS),
> you can use CA::Dispatch classes as mapping destinations, and the URL will
> be mapped correctly (that is: the way I want) and sent to the dispatch
> class.

I like with CAS that it can map to Dispatch and old school apps, although
it's rare I hae a project where I need to support both. 

Here's an API suggestion. Now there is:

  my $server = CGI::Application::Server->new();
  $server->document_root('./htdocs');
  $server->entry_points({
      '/index.cgi' => 'MyCGIApp',
      '/admin'     => 'MyCGIApp::Admin',
      '/account'   => 'MyCGIApp::Account::Dispatch',
  });
  $server->run();

If these are all common setup tasks, I'd like to see everything as options
to one method:

  my $server = CGI::Application::Server->run(
        document_root => './htdocs',
        entry_points  => {...},
        port          => 8081,
  );

####
   
   Mark














More information about the cgiapp mailing list