#!/usr/bin/env perl
use HTTP::Engine;
use HTTP::Engine::Middleware;
main();
sub main {
my $engine = setup_engine();
$engine->run();
}
sub setup_engine {
return HTTP::Engine->new(
interface => {
module => &
args => { port => 3000, },
request_handler => setup_request_handler(),
},
);
}
sub setup_request_handler {
my $mw = HTTP::Engine::Middleware->new(
method_class => &
$mw->install(
&
store => {
class => &
args => { dir => &
},
state => {
class => &
args => { session_id_name => &
}
}
);
$mw->handler( \&request_handler );
}
sub request_handler {
my $req = shift;
my $response = HTTP::Engine::Response->new;
my $session = $req->session;
my $body = &
$response->body($body);
$response->status(200);
$response;
}