Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Mangling
1. Mangling CPAN with Plack::App::Proxy Olaf Alders Toronto Perl Mongers September 30, 2010 [email_address] twitter.com/wundercounter
2. What is PSGI/Plack? “ Superglue interface between perl web application frameworks and web servers, just like Perl is the duct tape of the internet. PSGI is an interface between Perl web applications and web servers, and Plack is a Perl module and toolkit that contains PSGI middleware, helpers and adapters to web servers. PSGI and Plack are inspired by Python's WSGI and Ruby's Rack.” http://plackperl.org
23. Looking under the hood Let's look at how we went about setting up the proxy. It's very easy to set up. You can proxy a site of your choice in just a few minutes.
24. Set up the proxy use Plack::App::Proxy; use Plack::Builder; my $app = builder { mount "/" => builder {; Plack::App::Proxy->new( remote => 'http://search.cpan.org/' )->to_app; }; }; $app; # http://github.com/oalders/cpan-mangler/blob/master/examples/proxy.psgi
25. Mangle the POD use Plack::App::Proxy; use Plack::Builder; my $pod_highlight = q[...]; # insert JavaScript and CSS here my $app = builder { enable "Debug", panels => [qw(Environment Memory Timer Response)]; mount "/" => builder { enable 'SimpleContentFilter', filter => sub { s{</head>}{$pod_highlight</head>}i; }; Plack::App::Proxy->new( remote => 'http://search.cpan.org/' )->to_app; }; }; $app; # Find full code sample at # http://github.com/oalders/cpan-mangler/blob/master/examples/pod-mangler.psgi
26.
27. Can slow down page rendering on large pages (e.g. CGI.pm)