Skip to content

Commit 5b495cd

Browse files
veryrustyxsawyerx
authored andcommitted
Apply BehindProxy middleware when behind_proxy is set
set behind_proxy => 1; We now 'use' the middleware directly rather than letting Plack::Builder load it for us. May allow earlier version of Plack to be used as a dependency.
1 parent d172de8 commit 5b495cd

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

lib/Dancer2/Core/App.pm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use Plack::Middleware::FixMissingBodyInRedirect;
1717
use Plack::Middleware::Head;
1818
use Plack::Middleware::Conditional;
1919
use Plack::Middleware::ConditionalGET;
20+
use Dancer2::Middleware::BehindProxy;
2021

2122
use Dancer2::FileUtils 'path';
2223
use Dancer2::Core;
@@ -1419,10 +1420,15 @@ sub to_app {
14191420

14201421
# Wrap with common middleware
14211422
if ( ! $self->config->{'no_default_middleware'} ) {
1423+
# BehindProxy (this is not runtime configurable)
1424+
$self->config->{'behind_proxy'}
1425+
and $psgi = Dancer2::Middleware::BehindProxy->wrap($psgi);
1426+
14221427
# FixMissingBodyInRedirect
1423-
$psgi = Plack::Middleware::FixMissingBodyInRedirect->wrap( $psgi );
1428+
$psgi = Plack::Middleware::FixMissingBodyInRedirect->wrap($psgi);
1429+
14241430
# Apply Head. After static so a HEAD request on static content DWIM.
1425-
$psgi = Plack::Middleware::Head->wrap( $psgi );
1431+
$psgi = Plack::Middleware::Head->wrap($psgi);
14261432
}
14271433

14281434
return $psgi;

lib/Dancer2/Core/Runner.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use Module::Runtime 'require_module';
77
use Dancer2::Core::MIME;
88
use Dancer2::Core::Types;
99
use Dancer2::Core::Dispatcher;
10-
use Plack::Builder qw();
1110
use Ref::Util qw< is_ref is_regexpref >;
1211

1312
# Hashref of configurable items for the runner.

0 commit comments

Comments
 (0)