I looked at a variation of the place to find the best way to maintain a directory of static files from mojolicious , and it was as close as I could:
package ExampleServer;
use Mojo::Base 'Mojolicious';
use Mojolicious::Static;
sub startup {
my $self = shift;
$ENV{MOJO_REVERSE_PROXY} = 1;
my $static_path = '/www/example/docroot/.well-known/acme-challenge/';
my $r = $self->routes;
$r->get('/')->to('example#welcome');
$r->get('/.well-known/acme-challenge/*filename' => sub {
my $self = shift;
my $filename = $self->stash('filename');
my $fqfn = $static_path . $filename;
$self->app->log->debug($fqfn);
my $static = Mojolicious::Static->new( paths => [ $static_path ] );
$static->serve($self, $fqfn);
$self->rendered;
});
}
1;
This pulls out the file name correctly and it only affects the url I want, but it serves empty files regardless of whether they exist in this directory or not. What am I missing?
source
share