Requiring users to create anonymous subs is tedious and
Plack::Component is already a part of Plack (and installed
by all PSGI users) and already used by many middlewares.
package PublicInbox::WwwStatic;
use strict;
use v5.10.1;
-use parent qw(Exporter);
+use parent qw(Exporter Plack::Component);
use autodie qw(sysseek);
use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
use HTTP::Date qw(time2str);
use v5.12;
use Plack::Builder;
use PublicInbox::WwwStatic;
-my \$ws = PublicInbox::WwwStatic->new(docroot => "$tmpdir" @_);
-builder { sub { \$ws->call(shift) } }
+PublicInbox::WwwStatic->new(docroot => "$tmpdir" @_)->to_app;
EOM
{ psgi_file => $ret, TMPDIR => "$tmpdir" };
};