a reviravolta do
desenvolvimento web
Wallace Reis

YAPC::BR - São Paulo/2012
eu
@wreis - wallace@reis.me
vitória.pm
yelster digital
123people.com - frontend lead-dev
123pages.fr
reporama.com
eu
@wreis - wallace@reis.me
vitória.pm
yelster digital
123people.com - frontend lead-dev
123pages.fr
reporama.com
eu
@wreis - wallace@reis.me
vitória.pm
yelster digital
123people.com - frontend lead-dev
123pages.fr
reporama.com
caótico!
...de escrever...
Catalyst

Tripletail

Noe

Maypole

Konstrukt

Schenker

Mason

Reaction

Tatsumaki

Mojo

Jifty

Amon

Sledge

Cyclone3

Apache2::WebApp

Spoon

WebGUI

Web::Simple

PageKit

OpenInteract

Apache2::REST

AxKit

Squatting

SweetPea

Egg

Dancer

Hydrant

Gantry

CGI::Application

Titanium

Continuity

Nanoa

CGI.pm

Solstice

Ark

Mojolicious

Angelos
...de executar...
CGI
FastCGI
mod_perl
standalone HTTP
CGI.pm
Jifty, CGI::Application, Spoon...
mod_perl
Mason, Sledge, PageKit...
com adaptadores
Maypole, Catalyst, Squatting...
HTTP::Engine
PSGI
Internet
PSGI
Perl Web Server Gateway Interface
Tatsuhiko Miyagawa
WSGI (Python) e Rack (Ruby)
PSGI
Perl Web Server Gateway Interface
Tatsuhiko Miyagawa
WSGI (Python) e Rack (Ruby)
PSGI
Perl Web Server Gateway Interface
Tatsuhiko Miyagawa
WSGI (Python) e Rack (Ruby)
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
Streaming e/ou
non-blocking?
my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
# ... delegar
$respond->(
[$status, $headers, $body]
);
};
};
my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
my $w = $respond->([$status, $headers]);
$w->write($body);
...
$w->close;
};
};
PSGI

...
PSGI

SPDY?
Plack?
Plack?

PSGI toolkit
HTTP::Server::PSGI
Plack::Component
Plack::(Request|Response)
Plack::Middleware
220+ Middleware
my $app = sub {
my $env = shift;
return [ $status, $headers, $body ];
};
my $mw = sub { ... };
my $mw = sub {
my $env = shift;
# ...faz algo com (ou no) $env
my $res = $app->($env);
# faz algo com a (ou na) $res
return $res;
};
package My::Middleware;
use
use
use
use

strict;
warnings;
Plack::Request;
parent ‘Plack::Middleware’;

sub call {
my ( $self, $env ) = @_;
# ...faz algo com (ou no) $env
# my $req = Plack::Request->new($env);
my $res = $app->($env);
# faz algo com a (ou na, ou nova) $res
# my $res = $req->new_response;
return $res;
}
1;
Plack::Util::response_cb
$ plackup app.psgi
HTTP::Server::PSGI: Accepting connections
at http:/
/0:5000/
$ plackup -s $SERVER app.psgi
$ plackup -s FCGI app.psgi
$ plackup -s Starman app.psgi
use Plack::Builder;
my $app = MyApp->psgi_app; # ->to_psgi; ->to_app; >as_psgi; etc
builder {
enable ‘Static’, ...;
enable_if {
$_[0]->{'PATH_INFO'} =~ m{^/admin}
} 'Auth::Htpasswd', ...;
};

$app;
Plack::App
Plack::App::File
Plack::App::Directory
Plack::App::Proxy
Plack::App::FCGIDispatcher
Plack::App::URLMap
use Plack::Builder;
my $app = MyApp->psgi_app; # ->to_psgi; ->to_app; ->as_psgi; etc
builder {
enable ‘Static’, ...;
enable_if {
$_[0]->{'PATH_INFO'} =~ m{^/admin}
} 'Auth::Htpasswd', ...;
mount ‘/foo’ => $foo_app;
mount ‘http:/
/www.example.com/’ => builder {
enable ‘AccessLog’, ...;
$bar_app;
};
};

mount ‘/’ => $app;
Plack::App::CGIBin
Plack::App::WrapCGI
Plack::App::FakeApache
Plack::Test
Test::WWW::Mechanize::PSGI
25+ Frameworks e
Toolkits
35+ Webservers e
Handlers
25+ Frameworks e
Toolkits
35+ Webservers e
Handlers
CGI

Plack::Handler::CGI
mod_perl

Plack::Handler::Apache(1|2)
FastCGI
Plack::Handler::FCGI
::FCGI::EV
::FCGI::Async
::AnyEvent::FCGI
fastpass
FastCGI
Plack::Handler::FCGI
::FCGI::EV
::FCGI::Async
::AnyEvent::FCGI
fastpass
FastCGI
Plack::Handler::FCGI
::FCGI::EV
::FCGI::Async
::AnyEvent::FCGI
fastpass
Servidores HTTP
autônomos
HTTP::Server::PSGI
HTTP::Server::Simple::PSGI
Starman
Starlet
Servidores HTTP
autônomos
HTTP::Server::PSGI
HTTP::Server::Simple::PSGI
Starman
Starlet
Servidores HTTP
autônomos
HTTP::Server::PSGI
HTTP::Server::Simple::PSGI
Starman
Starlet
Servidores HTTP
autônomos
HTTP::Server::PSGI
HTTP::Server::Simple::PSGI
Starman
Starlet
Servidores HTTP
autônomos (async)
Feersum
Twiggy
Perlbal::Plugin::PSGI
mod_psgi
nginx_mod_psgi
Mongrel2
Obrigado! Perguntas?
Wallace Reis @wreis
wallace@reis.me

YAPC::BR::2012

https:/
/metacpan.org/module/PSGI
http:/
/plackperl.org/
http:/
/blog.plackperl.org/
IRC#plack

A reviravolta do desenvolvimento web