Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use PlackX::Engine

  • Loading branch information...
commit fe631efaebcd777492c074ca86157e837bc2be74 1 parent 8598024
@dann authored
View
1  angelos-core/Makefile.PL
@@ -55,6 +55,7 @@ requires(
'Class::Singleton' => 0,
'CHI' => '0.10',
'Plack' => 0,
+ 'PlackX::Engine' => 0,
# Angelos Plugins
'Text::SimpleTable' => 0,
View
4 angelos-core/lib/Angelos/Engine.pm
@@ -46,6 +46,10 @@ sub build_dispatcher {
sub handle_request {
my ( $self, $req ) = @_;
+ my $c = $self->create_context( $req, $res );
+ no warnings 'redefine';
+ local *Angelos::Registrar::context = sub {$c};
+
eval { $self->DISPATCH($req); };
if ( my $e = Exception::Class->caught() ) {
$self->HANDLE_EXCEPTION($e);
View
54 angelos-core/lib/Angelos/Engine/Base.pm
@@ -4,6 +4,7 @@ use Carp ();
use Angelos::Exceptions;
use Angelos::PSGI::Engine;
use Angelos::Request;
+use PlackX::Engine;
with 'Angelos::Class::Loggable';
@@ -62,54 +63,27 @@ sub BUILD {
sub SETUP { }
sub build_engine {
- my $self = shift;
- my $request_handler = $self->request_handler;
+ my $self = shift;
+ my $request_handler ||= $self->request_handler;
$request_handler ||= $self->build_request_handler;
- return Angelos::PSGI::Engine->new(
- interface => {
- module => $self->server,
- args => {
- host => $self->host,
- port => $self->port,
- root => $self->root,
+ my $engine = PlackX::Engine->new(
+ { server => {
+ module => $self->server,
+ args => {
+ port => $self->port,
+ host => $self->host,
+ },
},
- },
- psgi_handler => $request_handler,
+ request_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;
- return sub {
- 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;
+ return sub { my $req = shift; $self->handle_request($req) }
}
sub handle_request {
View
24 angelos-core/lib/Angelos/PSGI/Adapter.pm
@@ -1,24 +0,0 @@
-package Angelos::PSGI::Adapter;
-use strict;
-use warnings;
-use UNIVERSAL::require;
-
-sub new {
- my ( $class, $app ) = @_;
- bless { app => $app }, $class;
-}
-
-sub handler {
- my $self = shift;
- my $app = $self->_new_app;
- return sub { $app->run };
-}
-
-sub _new_app {
- my $self = shift;
- my $app = $self->{app};
- $app->require;
- $app->new;
-}
-
-1;
View
20 angelos-core/lib/Angelos/PSGI/Engine.pm
@@ -1,20 +0,0 @@
-package Angelos::PSGI::Engine;
-use Mouse;
-use Angelos::Types qw( ServerGateway );
-
-has 'interface' => (
- is => 'ro',
- isa => ServerGateway,
- coerce => 1,
-);
-
-has 'psgi_handler' => ( is => 'rw', );
-
-sub run {
- my $self = shift;
- $self->interface->run( $self->psgi_handler );
-}
-
-__PACKAGE__->meta->make_immutable( inline_destructor => 1 );
-1;
-
View
13 angelos-core/lib/Angelos/PSGI/ServerGatewayBuilder.pm
@@ -1,13 +0,0 @@
-package Angelos::PSGI::ServerGatewayBuilder;
-use strict;
-use warnings;
-use Plack::Loader;
-
-sub build {
- my ( $class, $module, $args ) = @_;
- my $server_gateway = Plack::Loader->load( $module, %{$args} );
- $server_gateway;
-}
-
-1;
-
1  angelos-plugins/Angelos-Controller-Plugin-Dumper
@@ -1 +0,0 @@
-Subproject commit 16e076c82a37511ad5113e4f73d5e913ee29b8ad
1  angelos-plugins/Angelos-Controller-Plugin-FillinForm
@@ -1 +0,0 @@
-Subproject commit 234a80b47b772a8ecc49adc959dc3e943aa44052
1  angelos-plugins/Angelos-Controller-Plugin-FormValidator-Simple
@@ -1 +0,0 @@
-Subproject commit 1b36282a51b6411c8e46f2cd241755aeece18810
1  angelos-tasks/Task-Angelos
@@ -1 +0,0 @@
-Subproject commit dbda7637edc1ba9f91d6fc3a32e8ce05027b4663
Please sign in to comment.
Something went wrong with that request. Please try again.