Evan Carroll
Evan Carroll

Reputation: 1

How do I hand off a Catalyst request to CGI::Application?

I have a CGI::Application loop like

while (my $q = new CGI::Fast){                                     
  S::W::Dispatch->dispatch(args_to_new => { QUERY => $q });
  my $webapp = S::W::instance();                           

  undef $CGI::Application::INSTANCE;                               
  S::W::instance(undef);                                   
  S::clear_instance();                                          
}

And, in short, I'd like to make that a new Catalyst dispatch..

So I want to do something like this

sub oldRoot :Local {
  ...
  S::W::Dispatch->dispatch(args_to_new => { QUERY => $q });
}

So I need to know how to reconstruct the $q in Catalyst. Is this easily done? Or, how do I achive this easier?

Upvotes: 2

Views: 56

Answers (1)

Evan Carroll
Evan Carroll

Reputation: 1

This was actually a lot easier than I expected.

Simply make your controller extend Catalyst::Controller::WrapCGI, rather than Catalyst::Controller

BEGIN { extends 'Catalyst::Controller::WrapCGI' }

Then wrap the whole thing like this..

$self->cgi_to_response($c, sub {                                    
  my $q = new CGI::Fast;                                            
  S::W::Dispatch->dispatch(args_to_new => { QUERY => $q }); 
  my $webapp = S::W::instance();                            
  undef $CGI::Application::INSTANCE;                                
  S::W::instance(undef);                                    
  S::clear_instance();                                           
} );

It just worked..

Upvotes: 2

Related Questions