Skip to content

Commit

Permalink
Merge branch 'fix/gh-975'
Browse files Browse the repository at this point in the history
  • Loading branch information
cromedome committed Dec 21, 2016
2 parents a171120 + e4c4109 commit 0234f4e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{$NEXT}}

[ BUG FIXES ]
* GH #975: Fix "public_dir" configuration to work, just like
DANCER_PUBLIC. (Sawyer X)

[ ENHANCEMENTS ]
* You can now call '$self->find_plugin(...)' within a plugin
in order to find a plugin, in order to use its DSL in your
Expand Down
6 changes: 5 additions & 1 deletion lib/Dancer2/Core/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ sub _build_default_config {
environment => $self->environment,
appdir => $self->location,
public_dir => $public,
static_handler => ( -d $public ),
template => 'Tiny',
route_handlers => [
[
Expand Down Expand Up @@ -1099,6 +1098,11 @@ sub BUILD {

sub finish {
my $self = shift;

# normalize some values that require calculations
defined $self->config->{'static_handler'}
or $self->config->{'static_handler'} = -d $self->config->{'public_dir'};

$self->register_route_handlers;
$self->compile_hooks;

Expand Down
1 change: 1 addition & 0 deletions t/issues/gh-975/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public_dir: "t/issues/gh-975/test_public_dir"
15 changes: 15 additions & 0 deletions t/issues/gh-975/gh-975.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use strict;
use warnings;
use Test::More 'tests' => 2;
use Plack::Test;
use HTTP::Request::Common;

{
package App;
use Dancer2;
}

my $test = Plack::Test->create( App->to_app );
my $res = $test->request( GET '/test.txt' );
ok( $res->is_success, 'Succeeded retrieving file' );
like( $res->content, qr{^this is test\.txt}, 'Correct file content' );
1 change: 1 addition & 0 deletions t/issues/gh-975/test_public_dir/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is test.txt

0 comments on commit 0234f4e

Please sign in to comment.