Use Plack::Loader and push the running of plack back into the engine code. Unsure...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index d2accd8..a9c3da3 100644 (file)
@@ -11,6 +11,7 @@ use HTTP::Body;
 use HTTP::Headers;
 use URI::QueryParam;
 use Moose::Util::TypeConstraints;
+use Plack::Loader;
 
 use namespace::clean -except => 'meta';
 
@@ -747,8 +748,14 @@ Start the engine. Implemented by the various engine classes.
 =cut
 
 sub run {
-    my ($self, $app) = @_;
+    my ($self, $app, @args) = @_;
+    Carp::cluck("Run");
+    # FIXME - Do something sensible with the options we're passed
+    $self->_run_psgi_app($self->_build_psgi_app($app, @args), @args);
+}
 
+sub _build_psgi_app {
+    my ($self, $app, @args) = @_;
     return sub {
         my ($env) = @_;
 
@@ -760,6 +767,12 @@ sub run {
     };
 }
 
+sub _run_psgi_app {
+    my ($self, $psgi_app, @args);
+    # FIXME - Need to be able to specify engine and pass options..
+    Plack::Loader->auto()->run($psgi_app);
+}
+
 =head2 $self->write($c, $buffer)
 
 Writes the buffer to the client.