From 8c93a4285959bca0d22273d57f7c4969a38a5453 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 10 Jun 2025 05:18:10 +0000 Subject: [PATCH] www_static: use Plack::Component->to_app 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 | 2 +- t/www_static.t | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/WwwStatic.pm b/lib/PublicInbox/WwwStatic.pm index 67549c7b9..d54f4cdbd 100644 --- a/lib/PublicInbox/WwwStatic.pm +++ b/lib/PublicInbox/WwwStatic.pm @@ -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); diff --git a/t/www_static.t b/t/www_static.t index e258be1cf..57814a13e 100644 --- a/t/www_static.t +++ b/t/www_static.t @@ -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" }; }; -- 2.47.3