0
Plack
Superglue for Perl Web Frameworks
         Tatsuhiko Miyagawa
           YAPC::NA 2010
Tatsuhiko Miyagawa

• Lives in San Francisco
• Software Engineer @ Six Apart
• http://search.cpan.org/~miyagawa/
• @miyaga...
Web Applications
Hello World
#!/usr/bin/perl
use strict;

print “Content-Type: text/plainrnrn”;
print “Hello World”;
use FCGI;

my $req = FCGI::Request();
while ($req->Accept >= 0) {
  print “Content-Type: text/plainrnrn”;
  print “Hello W...
package HelloWorld;
use strict;
use Apache::RequestRec;
use Apache::RequestIO;
use Apache::Const -compile => qw(OK);

sub ...
package HelloWorld;
use base qw(HTTP::Server::Simple::CGI);

sub handle_request {
  my($self, $cgi) = @_;
  print “HTTP/1....
All similar
but slightly different
Painful to support
   all of them :(
There is (was)
one common way
 to do all of this.
#!/usr/bin/perl
use CGI;

my $q = CGI->new;

print $q->header(‘text/plain’);
print “Hello World”;
Happens to work on:
    CGI, FastCGI, mod_perl
  (HTTP::Server::Simple::CGI)
CGI.pm

mod_perl    CGI     fastcgi



Apache       IIS    lighttpd
CGI.pm?
  meh
Frameworks
to the rescue!
Maypole Mason Mojo Sledge Catalyst Spoon
 PageKit AxKit Egg Gantry Continuity Solstice
 Mojolicious Tripletail Konstrukt R...
MANY
web frameworks
Let’s look how they
handle web servers.
CGI.pm

mod_perl    CGI     fastcgi



Apache       IIS    lighttpd
CGI::Application




Apache             IIS   lighttpd
CGI::Application




             CGI.pm




Apache             IIS   lighttpd
CGI::Application




             CGI.pm

 mod_perl          CGI   fastcgi



Apache             IIS   lighttpd
CGI::Application         Jifty




             CGI.pm

 mod_perl          CGI     fastcgi



Apache             IIS      ...
CGI::Application         Jifty         Catalyst




             CGI.pm

 mod_perl          CGI     fastcgi



Apache     ...
CGI::Application         Jifty               Catalyst




             CGI.pm                  Catalyst::Engine


 mod_per...
CGI::Application         Jifty               Catalyst




             CGI.pm                  Catalyst::Engine


 mod_per...
CGI::Application         Jifty               Catalyst




                            CGI.pm                  Catalyst::En...
Mason          CGI::Application         Jifty               Catalyst




                            CGI.pm               ...
Mason           CGI::Application         Jifty               Catalyst




Mason::CGIHandler
                              ...
Gross.
CGI.pm
  Jifty, CGI::Application, Spoon


mod_perl centric
Mason, Sledge, PageKit, WebGUI


       Adapters
  Catalyst, Ma...
That was 2008.
Steal great idea
from Python/Ruby
WSGI (Python)
 Rack (Ruby)
WSGI (PEP-333)
# WSGI
def hello(environ, start_response):
 start_response(“200 OK”, [
   (‘Content-Type’, ‘text/plain’)
 ])
 return [“Hel...
WSGI
•   Django       •   mod_wsgi

•   Bottle       •   Paste

•   CherryPy     •   gunicorn

•   Tornado      •   uWSGI
...
Django              Bottle         Flask        Tornado


                                             WSGI middleware

  ...
Rack
# Rack
class Hello
 def call(env)
   return [
     200,
     { “Content-Type” => ”text/plain” },
     [“Hello World”]
   ]...
Rack
•   Rails       •   Unicorn

•   Merb        •   Thin

•   Sinatra     •   Mongrel

•   Camping     •   Rainbows!

• ...
Rails              Merb          Sinatra     Ramaze


                                         Rack middleware

          ...
PSGI
Perl Web Server Gateway Interface
Interface
# WSGI
def hello(environ, start_response):
 start_response(“200 OK”, [
   (‘Content-Type’, ‘text/plain’)
 ])
 return [“Hel...
# Rack
class Hello
 def call(env)
   return [
     200,
     { “Content-Type” => ”text/plain” },
     [“Hello World”]
   ]...
# PSGI
my $app = sub {
   my $env = shift;
   return [
      200,
      [ ‘Content-Type’, ‘text/plain’ ],
      [ ‘Hello W...
PSGI application
   code reference
   $app = sub {...};
my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};

        CGI-like environment variables
    ...
my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};


        Status code (int.): 200, 404 etc.
my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};

       Array reference of header pairs:
   ...
my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};

      Array reference of content chunks
   ...
That’s it.
(There’s a callback based streaming interface as well)
# PSGI
my $app = sub {
   my $env = shift;
   return [
      200,
      [ ‘Content-Type’, ‘text/plain’ ],
      [ ‘Hello W...
Now you’ve got
a PSGI application.
PSGI makes it
so simple to:
Write a new Perl
web app & framework
Write a new Perl
 web server
Mason           CGI::Application         Jifty               Catalyst




Mason::CGIHandler
                              ...
Catalyst            CGI::App              Jifty        Tatsumaki


                                                    Pla...
PSGI adaptation
Maypole Mason Mojo Sledge Catalyst Spoon PageKit
 AxKit Egg Gantry Continuity Solstice Mojolicious
Tripletail Konstrukt Re...
Maypole Mason Mojo Sledge Catalyst Spoon PageKit
 AxKit Egg Gantry Continuity Solstice Mojolicious
Tripletail Konstrukt Re...
Applications
Movable Type 6, WebGUI 8
# Catalyst
use MyApp;

MyApp->setup_engine(‘PSGI’);
my $app = sub { MyApp->run(@_) };

# $app is a PSGI app!
# Jifty
use MyPonyApp;
my $app = MyPonyApp->psgi_app;

# $app is a PSGI app!
# Dancer
use Dancer;

get ‘/’ => sub {
   “Hello World”;
};

dance; # returns a PSGI app!
# Mojolicious::Lite
use Mojolicious::Lite;

get ‘/:name’ => sub {
   my $self = shift;
   $self->render_text(‘Hello!’);
};...
# Web::Simple
use Web::Simple ‘MyApp’;

package MyApp;
dispatch {
  sub(GET) {
    [ 200, [...], [ ‘Hello’ ] ];
  }
};

my...
perldoc PSGI
If you want to adapt your framework to PSGI.
Plack
“PSGI toolkit”
HTTP::Server::PSGI
 Reference PSGI web server
      bundled in Plack
Plackup
Runs PSGI app instantly from CLI
      (inspired by rackup)
> plackup app.psgi
Plack::Handler
Connects PSGI apps to Web servers
   CGI, FastCGI, Apache, SCGI
PSGI Web Servers
Starman
UNIX Preforking HTTP servers (like Unicorn.rb)
  HTTP/1.1 chunk + keep-alives / Very Fast
Starlet
        Simpler UNIX HTTP/1.0 Server
Best used with Server::Starter and nginx/lighttpd
Twiggy
Non-blocking web server (like Thin.rb)
   based on AnyEvent framework
Corona
Coroutine for each connection based on Coro.pm
HTTP::Server::Simple::PSGI
 Zero-deps other than HTTP::Server::Simple
    Best for embedding PSGI applications
uWSGI
http://projects.unbit.it/uwsgi/
Perlbal plugin
http://github.com/miyagawa/Perlbal-Plugin-PSGI
nginx embedded perl
 http://github.com/yappo/nginx-psgi-patchs
mod_psgi
http://github.com/spiritloose/mod_psgi
evpsgi
http://github.com/sekimura/evpsgi
Feersum
http://github.com/stash/Feersum
Catalyst            CGI::App               Jifty        Tatsumaki


                                                     P...
Middleware
PSGI Middleware
 Wraps a PSGI application
to add pre/post processing
my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};

my $mw = sub {
   my $env = shift;
   # do ...
PSGI Middleware
  coderef -> coderef
 Higher-order functions
Middleware
   Debug, Session, Logger, Runtime, Static, Lint,
   AccessLog, ConditionalGET, ErrorDocument,
StackTrace, Auth...
Plack::Middleware
  reusable and extensible
  Middleware framework
 Plack::Builder DSL in .psgi
my $app = sub {
   return [ $status, $header, $body ];
};

use Plack::Builder;

builder {
  enable “Static”, root => “/htd...
plackup compatible
plackup -e ‘enable “Foo”;’ app.psgi
Middleware
Write once, run in every framework
DEMO
Plack::App::URLMap
    Multiplex multiple apps
 Integrated with Builder DSL
use CatApp;
use CGIApp;

my $c1 = sub { CatApp->run };
my $c2 = sub { CGIApp->run_psgi };

use Plack::Builder;

builder {
...
CGI::PSGI
Easy migration from CGI.pm
CGI::Emulate::PSGI
    CGI::Compile
Easiest migration from CGI scripts (like Registry)
Plack::Request
    like libapreq (Apache::Request)
wrapper APIs for middleware developers
Plack::Test
 Unified interface to write tests
with Mock HTTP and Live HTTP
use Plack::Test;
use HTTP::Request::Common;

my $app = sub {
   my $env = shift;
   return [ $status, $header, $body ];
};...
use Plack::Test;
use HTTP::Request::Common;
$Plack::Test::Impl = “Server”;

my $app = sub {
   my $env = shift;
   return ...
Plack::App::*
ready-to-use applications
Plack::App::Directory
   Static content file server
Plack::App::Proxy
    (non-blocking) proxy server
Can be used as reverse proxy as well
Plack::App::CGIBin
mount /cgi-bin as PSGI applications
Plack::App::FCGIDispatcher
   Connect to FCGI daemon
   (even in Ruby, Python, C)
Plack::App::JSP
Runs JavaScript PSGI apps :)
Testimonials
a.k.a. self-promotion
“I love this! It’s exactly the right answer to
 what i was looking for.” - Benjamin Trott
“Wow, this is nothing short of awesome.”
              - Stevan Little
“Plack is so simple, easy and powerful.”
              - Jesse Vincent
“Plack rocks. Miyagawa rocks.”
         - Piers Cawley
“Is he on too many drugs or too few? Either
  way let’s make sure that never changes.”
               - Matt S.Trout
Real World
Plack/PSGI
You should join!
> cpanm Plack
> cpanm Task::Plack
Cloud?
(Heroku, GAE)
Sunaba
http://sunaba.plackperl.org/
Runs on dankogai’s
    Sandbox
You can even try:
 system(“rm -fr /”);
     while (1) { }
Summary

• PSGI is an interface, Plack is the code.
• We have many (pretty fast) PSGI servers.
• We have adapters and tool...
Remember:
Plack is < 1y old
Lots of (exciting)
 things going on.
http://blog.plackperl.org/
http://github.com/miyagawa/Plack
        http://plackperl.org/
      irc://irc.perl.org/#plack
Questions?
Thank you!
Slides: http://slideshare.net/miyagawa
Plack at OSCON 2010
Plack at OSCON 2010
Plack at OSCON 2010
Plack at OSCON 2010
Plack at OSCON 2010
Upcoming SlideShare
Loading in...5
×

Plack at OSCON 2010

14,876

Published on

Published in: Technology
0 Comments
15 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
14,876
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
119
Comments
0
Likes
15
Embeds 0
No embeds

No notes for slide










































































































































  • Transcript of "Plack at OSCON 2010"

    1. 1. Plack Superglue for Perl Web Frameworks Tatsuhiko Miyagawa YAPC::NA 2010
    2. 2. Tatsuhiko Miyagawa • Lives in San Francisco • Software Engineer @ Six Apart • http://search.cpan.org/~miyagawa/ • @miyagawa • http://bulknews.typepad.com/
    3. 3. Web Applications
    4. 4. Hello World
    5. 5. #!/usr/bin/perl use strict; print “Content-Type: text/plainrnrn”; print “Hello World”;
    6. 6. use FCGI; my $req = FCGI::Request(); while ($req->Accept >= 0) { print “Content-Type: text/plainrnrn”; print “Hello World”; }
    7. 7. package HelloWorld; use strict; use Apache::RequestRec; use Apache::RequestIO; use Apache::Const -compile => qw(OK); sub handler { my $r = shift; $r->content_type(‘text/plain’); $r->print(“Hello World”); return Apache::Const::OK; } 1;
    8. 8. package HelloWorld; use base qw(HTTP::Server::Simple::CGI); sub handle_request { my($self, $cgi) = @_; print “HTTP/1.0 200 OKrn”; print “Content-Type: text/plainrnrn”; print “Hello World”; } 1;
    9. 9. All similar but slightly different
    10. 10. Painful to support all of them :(
    11. 11. There is (was) one common way to do all of this.
    12. 12. #!/usr/bin/perl use CGI; my $q = CGI->new; print $q->header(‘text/plain’); print “Hello World”;
    13. 13. Happens to work on: CGI, FastCGI, mod_perl (HTTP::Server::Simple::CGI)
    14. 14. CGI.pm mod_perl CGI fastcgi Apache IIS lighttpd
    15. 15. CGI.pm? meh
    16. 16. Frameworks to the rescue!
    17. 17. Maypole Mason Mojo Sledge Catalyst Spoon PageKit AxKit Egg Gantry Continuity Solstice Mojolicious Tripletail Konstrukt Reaction Jifty Cyclone3 WebGUI OpenInteract Squatting Dancer CGI::Application Nanoa Ark Angelos Noe Schenker Tatsumaki Amon Apache2::WebApp Web::Simple Apache2::REST SweetPea Hydrant Titanium
    18. 18. MANY web frameworks
    19. 19. Let’s look how they handle web servers.
    20. 20. CGI.pm mod_perl CGI fastcgi Apache IIS lighttpd
    21. 21. CGI::Application Apache IIS lighttpd
    22. 22. CGI::Application CGI.pm Apache IIS lighttpd
    23. 23. CGI::Application CGI.pm mod_perl CGI fastcgi Apache IIS lighttpd
    24. 24. CGI::Application Jifty CGI.pm mod_perl CGI fastcgi Apache IIS lighttpd
    25. 25. CGI::Application Jifty Catalyst CGI.pm mod_perl CGI fastcgi Apache IIS lighttpd
    26. 26. CGI::Application Jifty Catalyst CGI.pm Catalyst::Engine mod_perl CGI fastcgi Apache IIS lighttpd
    27. 27. CGI::Application Jifty Catalyst CGI.pm Catalyst::Engine mod_perl CGI fastcgi Apache IIS lighttpd nginx
    28. 28. CGI::Application Jifty Catalyst CGI.pm Catalyst::Engine mod_perl CGI fastcgi HTTP::Server ::Simple Apache IIS lighttpd nginx
    29. 29. Mason CGI::Application Jifty Catalyst CGI.pm Catalyst::Engine mod_perl CGI fastcgi HTTP::Server ::Simple Apache IIS lighttpd nginx
    30. 30. Mason CGI::Application Jifty Catalyst Mason::CGIHandler CGI.pm Catalyst::Engine mod_perl CGI fastcgi HTTP::Server ::Simple Apache IIS lighttpd nginx
    31. 31. Gross.
    32. 32. CGI.pm Jifty, CGI::Application, Spoon mod_perl centric Mason, Sledge, PageKit, WebGUI Adapters Catalyst, Maypole, Squatting
    33. 33. That was 2008.
    34. 34. Steal great idea from Python/Ruby
    35. 35. WSGI (Python) Rack (Ruby)
    36. 36. WSGI (PEP-333)
    37. 37. # WSGI def hello(environ, start_response): start_response(“200 OK”, [ (‘Content-Type’, ‘text/plain’) ]) return [“Hello World”]
    38. 38. WSGI • Django • mod_wsgi • Bottle • Paste • CherryPy • gunicorn • Tornado • uWSGI • Pylons • wsgiref • Flask • Google AppEngine
    39. 39. Django Bottle Flask Tornado WSGI middleware WSGI wsgi handlers Apache lighttpd nginx mod_wsgi GAE
    40. 40. Rack
    41. 41. # Rack class Hello def call(env) return [ 200, { “Content-Type” => ”text/plain” }, [“Hello World”] ] end end
    42. 42. Rack • Rails • Unicorn • Merb • Thin • Sinatra • Mongrel • Camping • Rainbows! • Ramaze • Phusion Passenger • etc. • Heroku
    43. 43. Rails Merb Sinatra Ramaze Rack middleware Rack Rack handlers Apache lighttpd Thin Unicorn Mongrel
    44. 44. PSGI Perl Web Server Gateway Interface
    45. 45. Interface
    46. 46. # WSGI def hello(environ, start_response): start_response(“200 OK”, [ (‘Content-Type’, ‘text/plain’) ]) return [“Hello World”]
    47. 47. # Rack class Hello def call(env) return [ 200, { “Content-Type” => ”text/plain” }, [“Hello World”] ] end end
    48. 48. # PSGI my $app = sub { my $env = shift; return [ 200, [ ‘Content-Type’, ‘text/plain’ ], [ ‘Hello World’ ], ]; };
    49. 49. PSGI application code reference $app = sub {...};
    50. 50. my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; CGI-like environment variables + psgi.input, psgi.errors etc.
    51. 51. my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; Status code (int.): 200, 404 etc.
    52. 52. my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; Array reference of header pairs: [ ‘Content-Type’, ‘text/html’, ... ]
    53. 53. my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; Array reference of content chunks Filehandle or IO::Handle-ish obejct
    54. 54. That’s it. (There’s a callback based streaming interface as well)
    55. 55. # PSGI my $app = sub { my $env = shift; return [ 200, [ ‘Content-Type’, ‘text/plain’ ], [ ‘Hello World’ ], ]; };
    56. 56. Now you’ve got a PSGI application.
    57. 57. PSGI makes it so simple to:
    58. 58. Write a new Perl web app & framework
    59. 59. Write a new Perl web server
    60. 60. Mason CGI::Application Jifty Catalyst Mason::CGIHandler CGI.pm Catalyst::Engine mod_perl CGI fastcgi HTTP::Server ::Simple Apache IIS lighttpd nginx
    61. 61. Catalyst CGI::App Jifty Tatsumaki Plack::Middleware PSGI Plack::Handler::* (CGI, FCGI, Apache) Apache lighttpd HTTP::Server::PSGI mod_psgi Perlbal
    62. 62. PSGI adaptation
    63. 63. Maypole Mason Mojo Sledge Catalyst Spoon PageKit AxKit Egg Gantry Continuity Solstice Mojolicious Tripletail Konstrukt Reaction Jifty Cyclone3 WebGUI OpenInteract Squatting Dancer CGI::Application Nanoa Ark Angelos Noe Schenker Tatsumaki Amon Apache2::WebApp Web::Simple Apache2::REST SweetPea Hydrant Titanium
    64. 64. Maypole Mason Mojo Sledge Catalyst Spoon PageKit AxKit Egg Gantry Continuity Solstice Mojolicious Tripletail Konstrukt Reaction Jifty Cyclone3 WebGUI OpenInteract Squatting Dancer CGI::Application Nanoa Ark Angelos Noe Schenker Tatsumaki Amon Apache2::WebApp Web::Simple Apache2::REST SweetPea Hydrant Titanium
    65. 65. Applications Movable Type 6, WebGUI 8
    66. 66. # Catalyst use MyApp; MyApp->setup_engine(‘PSGI’); my $app = sub { MyApp->run(@_) }; # $app is a PSGI app!
    67. 67. # Jifty use MyPonyApp; my $app = MyPonyApp->psgi_app; # $app is a PSGI app!
    68. 68. # Dancer use Dancer; get ‘/’ => sub { “Hello World”; }; dance; # returns a PSGI app!
    69. 69. # Mojolicious::Lite use Mojolicious::Lite; get ‘/:name’ => sub { my $self = shift; $self->render_text(‘Hello!’); }; app->start; # returns PSGI app
    70. 70. # Web::Simple use Web::Simple ‘MyApp’; package MyApp; dispatch { sub(GET) { [ 200, [...], [ ‘Hello’ ] ]; } }; my $app = MyApp->as_psgi; # $app is a PSGI app!
    71. 71. perldoc PSGI If you want to adapt your framework to PSGI.
    72. 72. Plack “PSGI toolkit”
    73. 73. HTTP::Server::PSGI Reference PSGI web server bundled in Plack
    74. 74. Plackup Runs PSGI app instantly from CLI (inspired by rackup)
    75. 75. > plackup app.psgi
    76. 76. Plack::Handler Connects PSGI apps to Web servers CGI, FastCGI, Apache, SCGI
    77. 77. PSGI Web Servers
    78. 78. Starman UNIX Preforking HTTP servers (like Unicorn.rb) HTTP/1.1 chunk + keep-alives / Very Fast
    79. 79. Starlet Simpler UNIX HTTP/1.0 Server Best used with Server::Starter and nginx/lighttpd
    80. 80. Twiggy Non-blocking web server (like Thin.rb) based on AnyEvent framework
    81. 81. Corona Coroutine for each connection based on Coro.pm
    82. 82. HTTP::Server::Simple::PSGI Zero-deps other than HTTP::Server::Simple Best for embedding PSGI applications
    83. 83. uWSGI http://projects.unbit.it/uwsgi/
    84. 84. Perlbal plugin http://github.com/miyagawa/Perlbal-Plugin-PSGI
    85. 85. nginx embedded perl http://github.com/yappo/nginx-psgi-patchs
    86. 86. mod_psgi http://github.com/spiritloose/mod_psgi
    87. 87. evpsgi http://github.com/sekimura/evpsgi
    88. 88. Feersum http://github.com/stash/Feersum
    89. 89. Catalyst CGI::App Jifty Tatsumaki Plack::Middleware PSGI Plack::Handler::* (CGI, FCGI, Apache) Apache lighttpd HTTP::Server::PSGI mod_psgi Perlbal Starman Twiggy uWSGI Corona evpsgi
    90. 90. Middleware
    91. 91. PSGI Middleware Wraps a PSGI application to add pre/post processing
    92. 92. my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; my $mw = sub { my $env = shift; # do something with $env my $res = $app->($env); # do something with $res; return $res; };
    93. 93. PSGI Middleware coderef -> coderef Higher-order functions
    94. 94. Middleware Debug, Session, Logger, Runtime, Static, Lint, AccessLog, ConditionalGET, ErrorDocument, StackTrace, Auth::Basic, Auth::Digest, ReverseProxy, Refresh, Auth::OAuth, Hippie, Throttle
    95. 95. Plack::Middleware reusable and extensible Middleware framework Plack::Builder DSL in .psgi
    96. 96. my $app = sub { return [ $status, $header, $body ]; }; use Plack::Builder; builder { enable “Static”, root => “/htdocs”, path => qr!^/static/!; enable “Deflater”; # gzip/deflate $app; }
    97. 97. plackup compatible plackup -e ‘enable “Foo”;’ app.psgi
    98. 98. Middleware Write once, run in every framework
    99. 99. DEMO
    100. 100. Plack::App::URLMap Multiplex multiple apps Integrated with Builder DSL
    101. 101. use CatApp; use CGIApp; my $c1 = sub { CatApp->run }; my $c2 = sub { CGIApp->run_psgi }; use Plack::Builder; builder { mount “/cat” => $c1; mount “/cgi-app” => builder { enable “StackTrace”; $c2; }; }
    102. 102. CGI::PSGI Easy migration from CGI.pm
    103. 103. CGI::Emulate::PSGI CGI::Compile Easiest migration from CGI scripts (like Registry)
    104. 104. Plack::Request like libapreq (Apache::Request) wrapper APIs for middleware developers
    105. 105. Plack::Test Unified interface to write tests with Mock HTTP and Live HTTP
    106. 106. use Plack::Test; use HTTP::Request::Common; my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; test_psgi app => $app, client => sub { my $cb = shift; my $req = GET “http://localhost/foo”; my $res = $cb->($req); # test $res; };
    107. 107. use Plack::Test; use HTTP::Request::Common; $Plack::Test::Impl = “Server”; my $app = sub { my $env = shift; return [ $status, $header, $body ]; }; test_psgi app => $app, client => sub { my $cb = shift; my $req = GET “http://localhost/foo”; my $res = $cb->($req); # test $res; };
    108. 108. Plack::App::* ready-to-use applications
    109. 109. Plack::App::Directory Static content file server
    110. 110. Plack::App::Proxy (non-blocking) proxy server Can be used as reverse proxy as well
    111. 111. Plack::App::CGIBin mount /cgi-bin as PSGI applications
    112. 112. Plack::App::FCGIDispatcher Connect to FCGI daemon (even in Ruby, Python, C)
    113. 113. Plack::App::JSP Runs JavaScript PSGI apps :)
    114. 114. Testimonials a.k.a. self-promotion
    115. 115. “I love this! It’s exactly the right answer to what i was looking for.” - Benjamin Trott
    116. 116. “Wow, this is nothing short of awesome.” - Stevan Little
    117. 117. “Plack is so simple, easy and powerful.” - Jesse Vincent
    118. 118. “Plack rocks. Miyagawa rocks.” - Piers Cawley
    119. 119. “Is he on too many drugs or too few? Either way let’s make sure that never changes.” - Matt S.Trout
    120. 120. Real World Plack/PSGI
    121. 121. You should join!
    122. 122. > cpanm Plack > cpanm Task::Plack
    123. 123. Cloud? (Heroku, GAE)
    124. 124. Sunaba http://sunaba.plackperl.org/
    125. 125. Runs on dankogai’s Sandbox
    126. 126. You can even try: system(“rm -fr /”); while (1) { }
    127. 127. Summary • PSGI is an interface, Plack is the code. • We have many (pretty fast) PSGI servers. • We have adapters and tools for most web frameworks. • Use it!
    128. 128. Remember: Plack is < 1y old
    129. 129. Lots of (exciting) things going on.
    130. 130. http://blog.plackperl.org/
    131. 131. http://github.com/miyagawa/Plack http://plackperl.org/ irc://irc.perl.org/#plack
    132. 132. Questions?
    133. 133. Thank you! Slides: http://slideshare.net/miyagawa
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×