use strict;
use warnings;
use lib 'lib';
BEGIN {
$ENV{JITENSYA_ROOT} = '/home/soozy/jitensya';
$ENV{JITENSYA_DEBUG} = 1;
$ENV{JITENSYA_MODE} = 'dev';
require Jitensya;
}
local_request('/app/');
sub local_request {
require HTTP::Request::AsCGI;
my $request = request( shift(@_) );
my $cgi = HTTP::Request::AsCGI->new( $request, %ENV )->setup;
Jitensya->handle_request;
return $cgi->restore->response;
}
sub request {
my $request = shift;
require HTTP::Request;
unless ( ref $request ) {
if ( $request =~ m/^http/i ) {
$request = URI->new($request)->canonical;
}
else {
$request = URI->new( 'http://localhost' . $request )->canonical;
}
}
unless ( ref $request eq 'HTTP::Request' ) {
$request = HTTP::Request->new( 'GET', $request );
}
return $request;
}
Catalyst inspired