]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
www_static: use Plack::Component->to_app
authorEric Wong <e@80x24.org>
Tue, 10 Jun 2025 05:18:10 +0000 (05:18 +0000)
committerEric Wong <e@80x24.org>
Fri, 13 Jun 2025 12:30:31 +0000 (12:30 +0000)
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.

lib/PublicInbox/WwwStatic.pm
t/www_static.t

index 67549c7b98dea4dc8f68f1f9cf7263c3cbd4628f..d54f4cdbd061951270976190f60c379e1307a401 100644 (file)
@@ -10,7 +10,7 @@
 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);
index e258be1cf892272d62f657d0070d7feffb544f15..57814a13e44cda9dcfb8fdbb14255314c5efca58 100644 (file)
@@ -17,8 +17,7 @@ my $psgi_env = sub { # @_ is passed to WwwStatic->new
 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" };
 };