The document discusses using Plack::App::Proxy middleware to create a proxy for the CPAN search site that adds syntax highlighting and formatting. It demonstrates how to set up the proxy with a simple PSGI application and modify the POD documentation and module source code views through content filtering. Known issues with the approach are listed, along with potential other uses of Plack proxies beyond modifying CPAN.
Report
Share
Report
Share
1 of 21
More Related Content
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
3. Plack::App::Proxy Plack middleware which allows you to map a local url to another local (or remote) url. Easier to set up than Apache's mod_proxy
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