2

我有一个CGI::Application像这样的循环

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();                                          
}

而且,简而言之,我想制作一个新的催化剂调度..

所以我想做这样的事情

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

所以我需要知道如何$q在 Catalyst 中重建。这很容易做到吗?或者,我如何更轻松地实现这一目标?

4

1 回答 1

2

这实际上比我预期的要容易得多。

只需让您的控制器扩展Catalyst::Controller::WrapCGI,而不是Catalyst::Controller

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

然后像这样包裹整个东西..

$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();                                           
} );

它刚刚工作..

于 2015-08-14T17:29:48.020 回答