Skip to content

Commit

Permalink
use PlackX::Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
dann committed Oct 2, 2009
1 parent 8598024 commit fe631ef
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 101 deletions.
1 change: 1 addition & 0 deletions angelos-core/Makefile.PL
Expand Up @@ -55,6 +55,7 @@ requires(
'Class::Singleton' => 0, 'Class::Singleton' => 0,
'CHI' => '0.10', 'CHI' => '0.10',
'Plack' => 0, 'Plack' => 0,
'PlackX::Engine' => 0,


# Angelos Plugins # Angelos Plugins
'Text::SimpleTable' => 0, 'Text::SimpleTable' => 0,
Expand Down
4 changes: 4 additions & 0 deletions angelos-core/lib/Angelos/Engine.pm
Expand Up @@ -46,6 +46,10 @@ sub build_dispatcher {


sub handle_request { sub handle_request {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
my $c = $self->create_context( $req, $res );
no warnings 'redefine';
local *Angelos::Registrar::context = sub {$c};

eval { $self->DISPATCH($req); }; eval { $self->DISPATCH($req); };
if ( my $e = Exception::Class->caught() ) { if ( my $e = Exception::Class->caught() ) {
$self->HANDLE_EXCEPTION($e); $self->HANDLE_EXCEPTION($e);
Expand Down
54 changes: 14 additions & 40 deletions angelos-core/lib/Angelos/Engine/Base.pm
Expand Up @@ -4,6 +4,7 @@ use Carp ();
use Angelos::Exceptions; use Angelos::Exceptions;
use Angelos::PSGI::Engine; use Angelos::PSGI::Engine;
use Angelos::Request; use Angelos::Request;
use PlackX::Engine;


with 'Angelos::Class::Loggable'; with 'Angelos::Class::Loggable';


Expand Down Expand Up @@ -62,54 +63,27 @@ sub BUILD {
sub SETUP { } sub SETUP { }


sub build_engine { sub build_engine {
my $self = shift; my $self = shift;
my $request_handler = $self->request_handler; my $request_handler ||= $self->request_handler;
$request_handler ||= $self->build_request_handler; $request_handler ||= $self->build_request_handler;


return Angelos::PSGI::Engine->new( my $engine = PlackX::Engine->new(
interface => { { server => {
module => $self->server, module => $self->server,
args => { args => {
host => $self->host, port => $self->port,
port => $self->port, host => $self->host,
root => $self->root, },
}, },
}, request_handler => $request_handler,
psgi_handler => $request_handler, }
); );
}

sub build_request_handler {
my $self = shift;


# FIXME wrap application handler Angelos::Middleware::Builder
my $app_handler = $self->create_application_handler;
return $app_handler;
} }


sub create_application_handler { sub build_request_handler {
my $self = shift; my $self = shift;
return sub { return sub { my $req = shift; $self->handle_request($req) }
my $env = shift;
my $req = Angelos::Request->new($env);
my $res = Angelos::Response->new;
my $c = $self->create_context( $req, $res );
no warnings 'redefine';
local *Angelos::Registrar::context = sub {$c};

$res = $self->handle_request($req);
my $psgi_res = $self->finalize_response($res);
return $psgi_res;
};
}

sub finalize_response {
my ( $self, $res ) = @_;
my $psgi_res = $res->finalize;
$psgi_res->[1] = [ %{ $psgi_res->[1] } ]
if ref( $psgi_res->[1] ) eq 'HASH';
$psgi_res->[2] = [ $psgi_res->[2] ] unless ref( $psgi_res->[2] );
$psgi_res;
} }


sub handle_request { sub handle_request {
Expand Down
24 changes: 0 additions & 24 deletions angelos-core/lib/Angelos/PSGI/Adapter.pm

This file was deleted.

20 changes: 0 additions & 20 deletions angelos-core/lib/Angelos/PSGI/Engine.pm

This file was deleted.

13 changes: 0 additions & 13 deletions angelos-core/lib/Angelos/PSGI/ServerGatewayBuilder.pm

This file was deleted.

1 change: 0 additions & 1 deletion angelos-plugins/Angelos-Controller-Plugin-Dumper
Submodule Angelos-Controller-Plugin-Dumper deleted from 16e076
1 change: 0 additions & 1 deletion angelos-plugins/Angelos-Controller-Plugin-FillinForm
Submodule Angelos-Controller-Plugin-FillinForm deleted from 234a80
Submodule Angelos-Controller-Plugin-FormValidator-Simple deleted from 1b3628
1 change: 0 additions & 1 deletion angelos-tasks/Task-Angelos
Submodule Task-Angelos deleted from dbda76

0 comments on commit fe631ef

Please sign in to comment.