Plack::Middleware::ESI - PSGI middleware for Edge Side Includes (ESI)
version 0.1
use Plack::Builder; my $app = sub { return [ 200, [ 'Content-Type' => 'text/plain' ], [ "The Google front page as plaintext: ", '<esi:include src="http://google.com/" />', "And a local request might be nice: ", '<esi:include src="/userinfo/" />', ] ]; }; builder { enable "ESI"; $app; };
This module provides rudimentary support for using Edge Side Includes in PSGI applications.
The primary aim is to support the same subset of features as the Varnish caching proxy server. Essentially, this means support for three ESI tags:
<esi:include src="..." /> - Include the contents of a remote or a local URL. Please note that the alt and onerror attributes are not supported.
<esi:include src="..." />
alt
onerror
<esi:remove>...</esi:remove> - Remove a section of the document.
<esi:remove>...</esi:remove>
<!--esi ...--> - Unhide whataver is inside the HTML/XML comment (which is normally the result of applying an ESI include tag).
<!--esi ...-->
The module only filters responses with a Content-Type of text/*, application/xml, or application/xhtml+xml. This obviously means that the Content-Type output header must have been set further down in the middleware stack (or, of course, in the original PSGI app itself), before the ESI middleware is applied.
text/*
application/xml
application/xhtml+xml
Baldur Kristinsson <bk@mbl.is>
Varnish ESI support: http://www.varnish-cache.org/trac/wiki/ESIfeatures
ESI 1.0 Specification: http://www.w3.org/TR/esi-lang
To install Plack::Middleware::ESI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::ESI
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::ESI
For more information on module installation, please visit the detailed CPAN module installation guide.