X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FWeb%2FSimple%2FApplication.pm;h=70339faf8982137e96faf08f48cdc3b2aa56c010;hb=d3a6160961a582183cfc02efc5e0a09039bd10dd;hp=c00c50c92a03e780841e02f6f82b6267e1f4bc71;hpb=93e30ba3c4409bccc1a8deb483acab6a8e3fc8c4;p=catagits%2FWeb-Simple.git diff --git a/lib/Web/Simple/Application.pm b/lib/Web/Simple/Application.pm index c00c50c..70339fa 100644 --- a/lib/Web/Simple/Application.pm +++ b/lib/Web/Simple/Application.pm @@ -223,7 +223,8 @@ sub _run_with_self { } sub run_if_script { - return 1 if caller(1); # 1 so we can be the last thing in the file + # ->as_psgi_app is true for require() but also works for plackup + return $_[0]->as_psgi_app if caller(1); my $class = shift; my $self = $class->new; $self->run(@_); @@ -232,7 +233,12 @@ sub run_if_script { sub _run_cgi { my $self = shift; require Web::Simple::HackedPlack; - Plack::Server::CGI->run(sub { $self->_dispatch(@_) }); + Plack::Server::CGI->run($self->as_psgi_app); +} + +sub as_psgi_app { + my $self = shift; + ref($self) ? sub { $self->_dispatch(@_) } : sub { $self->new->_dispatch(@_) } } sub run {