+### Get whether or not we are running as a PSGI app
+# my $app = CGI::Ex::App::PSGI->psgi_app('Foo::Bar::App');
+# $app->is_psgi; # is true
+sub is_psgi { shift->object->isa('CGI::PSGI') }
+
+### Allow for generating a PSGI response
+sub psgi_response {
+ my $self = shift;
+
+ $self->{psgi_responded} = 1;
+ $self->print_content_type;
+
+ if (my $location = $self->{psgi_location}) {
+ return [302, ['Content-Type' => 'text/html', Location => $location], ["Bounced to $location\n"]];
+ } else {
+ return [$self->{psgi_status} || 200, $self->{psgi_headers} || [], $self->{psgi_body} || ['']];
+ }
+}
+
+### Allow for sending a PSGI streaming/delayed response
+sub psgi_respond {
+ my $self = shift;
+ if ($self->{psgi_responder}) {
+ my $response = $self->psgi_response;
+ delete $response->[2];
+ $self->{psgi_writer} = $self->{psgi_responder}->($response);
+ delete $self->{psgi_responder};
+ }
+ $self->{psgi_writer};
+}
+
+###----------------------------------------------------------------###
+