Created
October 17, 2009 15:49
-
-
Save gugod/212377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use UNIVERSAL::require; | |
| use HTTP::Message; | |
| use YAML; | |
| use CGI::PSGI; | |
| BEGIN { | |
| Jifty::Util->require or die $UNIVERSAL::require::ERROR; | |
| # XXX: Anyway to figure this out automatically ? | |
| my $root = $ENV{JIFTY_APP_ROOT} = "/Users/gugod/src/Pony"; | |
| unshift @INC, "$root/lib"; | |
| } | |
| use Jifty; | |
| chdir($ENV{'JIFTY_APP_ROOT'}); | |
| Jifty->new; | |
| sub app { | |
| my $env = shift; | |
| local *ENV = $env; | |
| my ($status, $headers, $body); | |
| my $out; | |
| local *STDOUT; | |
| open STDOUT, ">", \$out; | |
| Jifty->handler->add_trigger( | |
| before_cleanup => sub { | |
| my $r = Jifty->handler->apache; | |
| $headers = $r->headers_out; | |
| $status = delete $headers->{Status} || '200 OK'; | |
| }); | |
| Jifty->handler->handle_request( cgi => CGI::PSGI->new($env) ); | |
| my $m = HTTP::Message->parse($out); | |
| $body = $m->content; | |
| close STDOUT; | |
| return [$status, [ %$headers ], [ $body ]]; | |
| } | |
| \&app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment