TPSGI.pm 756 B

1234567891011121314151617181920212223242526272829303132333435
  1. package Plack::Handler::TPSGI;
  2. use strict;
  3. use warnings;
  4. use parent qw{Plack::Handler::Starman};
  5. use TPSGI::Server;
  6. =head1 Plack::Handler::TPSGI
  7. Plack::Handler::Starman, running TPSGI::Server instead of Starman::Server.
  8. bin/tarbaby asks Plack::Runner for it as C<server =E<gt> 'TPSGI'>.
  9. =head2 run($app)
  10. Plack::Handler::Starman::run() names Starman::Server outright, so this is
  11. that, less its Server::Starter support, which tPSGI does not use.
  12. =cut
  13. sub run {
  14. my ( $self, $app ) = @_;
  15. my %nsa;
  16. foreach my $key ( keys %$self ) {
  17. ( my $name = $key ) =~ s/^net_server_// or next;
  18. $nsa{$name} = $self->{$key};
  19. }
  20. $self->{net_server_args} = \%nsa if %nsa;
  21. return TPSGI::Server->new->run( $app, {%$self} );
  22. }
  23. 1;