diff options
author | Eric Wong <e@80x24.org> | 2022-12-15 20:52:49 +0000 |
---|---|---|
committer | Eric Wong <mwrap-perl@80x24.org> | 2022-12-16 09:27:45 +0000 |
commit | 715e016a6736c81a0b2a7f19d964dd5db945e056 (patch) | |
tree | 9ae6ba20d4b2d0711c3bf8fe6a04d3d84f5e7545 | |
parent | 411ceeac6ca6be3fccec070086666d6b2df235bd (diff) | |
download | mwrap-715e016a6736c81a0b2a7f19d964dd5db945e056.tar.gz |
Ideally I want this in the main mwrap_httpd itself, but linking zlib may conflict with whatever an application uses. This will be useful for exposing the demo endpoint for public use.
-rw-r--r-- | script/mwrap-rproxy | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/script/mwrap-rproxy b/script/mwrap-rproxy index be6dcbe..a5572c5 100644 --- a/script/mwrap-rproxy +++ b/script/mwrap-rproxy @@ -8,10 +8,12 @@ use Plack::Runner; use Getopt::Long qw(:config no_ignore_case no_auto_abbrev pass_through); my $usage = "$0 --socket-dir=/path/to/socket-dir [PLACKUP_OPTIONS]\n"; my $socket_dir; -GetOptions('socket-dir=s' => \$socket_dir) or die $usage; +my $gz = 1; +GetOptions('socket-dir=s' => \$socket_dir, 'deflate!' => \$gz) or die $usage; $socket_dir //= ($ENV{MWRAP} // '') =~ m!\bsocket_dir:([^,]+)! ? $1 : undef; $socket_dir // die $usage; -my $app = Devel::Mwrap::Rproxy->new($socket_dir); +my $rproxy = Devel::Mwrap::Rproxy->new($socket_dir); +my $app = sub { $rproxy->call(@_) }; my $runner = Plack::Runner->new; $runner->parse_options(@ARGV); if (($ENV{LISTEN_PID} // 0) == $$) { @@ -26,4 +28,8 @@ Inherited socket (fd=3) is non-blocking, making it blocking. $runner->set_options(listen_sock => $s); } } -$runner->run(sub { $app->call(@_) }); +if ($gz) { + require Plack::Middleware::Deflater; + $app = Plack::Middleware::Deflater->wrap($app); +} +$runner->run($app); |