| 1 | package CPAN::Mini::Webserver::PSGI; | ||||||||||
| 2 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | $CPAN::Mini::Webserver::PSGI::VERSION = '0.01'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use CGI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use CGI::Emulate::PSGI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | extends 'CPAN::Mini::Webserver'; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub to_app { | ||||||||
|
Subroutine
to_app: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 14 | 1 | my ( $self ) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | $self = $self->new unless ref($self); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | $self->after_setup_listener; | |||||||||
| 19 | |||||||||||
| 20 | 24 | ▶ | return CGI::Emulate::PSGI->handler(sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 24 | CGI::initialize_globals(); | |||||||||
| 22 | 24 | my $cgi = CGI->new; | |||||||||
| 23 | 24 | return $self->handle_request($cgi); | |||||||||
| 24 | 1 | }); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 22 | ▶ | around send_http_header => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 22 | my ( $orig, $self, $code, %params ) = @_; | |||||||||
| 29 | |||||||||||
| 30 | 22 | $params{'-status'} = $code; | |||||||||
| 31 | 22 | return $self->$orig($code, %params); | |||||||||
| 32 | 2 | }; | |||||||||
| 33 | |||||||||||
| 34 | 2 | 1; | |||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | =pod | ||||||||||
| 39 | |||||||||||
| 40 | =head1 NAME | ||||||||||
| 41 | |||||||||||
| 42 | CPAN::Mini::Webserver::PSGI - Use CPAN::Mini::Webserver as a PSGI application | ||||||||||
| 43 | |||||||||||
| 44 | =head1 VERSION | ||||||||||
| 45 | |||||||||||
| 46 | version 0.01 | ||||||||||
| 47 | |||||||||||
| 48 | =head1 SYNOPSIS | ||||||||||
| 49 | |||||||||||
| 50 | # in your app.psgi file | ||||||||||
| 51 | use strict; | ||||||||||
| 52 | use warnings; | ||||||||||
| 53 | use CPAN::Mini::Webserver::PSGI; | ||||||||||
| 54 | |||||||||||
| 55 | CPAN::Mini::Webserver::PSGI->new->to_app; | ||||||||||
| 56 | # or CPAN::Mini::Webserver::PSGI->to_app as a shortcut | ||||||||||
| 57 | |||||||||||
| 58 | =head1 DESCRIPTION | ||||||||||
| 59 | |||||||||||
| 60 | CPAN::Mini::Webserver::PSGI is a simple extension of L<CPAN::Mini::Webserver> | ||||||||||
| 61 | that allows you to use L<CPAN::Mini::Webserver>'s functionality in a L<PSGI> | ||||||||||
| 62 | application. | ||||||||||
| 63 | |||||||||||
| 64 | CPAN::Mini::PSGIApp might be a better name for this module, but I wanted to | ||||||||||
| 65 | reflect its relationship to L<CPAN::Mini::Webserver>. | ||||||||||
| 66 | |||||||||||
| 67 | =head1 METHODS | ||||||||||
| 68 | |||||||||||
| 69 | This is a subclass of <CPAN::Mini::Webserver>, so it inherits all of its | ||||||||||
| 70 | methods. | ||||||||||
| 71 | |||||||||||
| 72 | =head2 to_app | ||||||||||
| 73 | |||||||||||
| 74 | Returns the L<PSGI> application for this CPAN::Mini::Webserver::PSGI instance. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 SEE ALSO | ||||||||||
| 77 | |||||||||||
| 78 | L<CPAN::Mini::Webserver>, L<PSGI> | ||||||||||
| 79 | |||||||||||
| 80 | =head1 AUTHOR | ||||||||||
| 81 | |||||||||||
| 82 | Rob Hoelz <rob@hoelz.ro> | ||||||||||
| 83 | |||||||||||
| 84 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 85 | |||||||||||
| 86 | This software is copyright (c) 2011 by Rob Hoelz. | ||||||||||
| 87 | |||||||||||
| 88 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 89 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | __END__ | ||||||||||