More Related Content
Similar to A reviravolta do desenvolvimento web (20)
A reviravolta do desenvolvimento web
- 25. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 26. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 27. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 28. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 29. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 30. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 31. my $app = sub {
my $env = shift;
return [
200,
[‘Content-Type’ => ‘text/plain’],
[‘Hello World’]
];
};
- 33. my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
# ... delegar
$respond->(
[$status, $headers, $body]
);
};
};
- 34. my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
my $w = $respond->([$status, $headers]);
$w->write($body);
...
$w->close;
};
};
- 47. my $app = sub {
my $env = shift;
return [ $status, $headers, $body ];
};
my $mw = sub { ... };
- 48. 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;
};
- 55. 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;
- 62. 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;
- 83. 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