shaneburgess
shaneburgess

Reputation: 15912

Add Static directory to Mojo Lite App

Hell all,

I am trying to add a shared static directory to my Mojo Lite app but this does not seem to do the trick.

use Mojolicious::Lite;
use Mojolicious::Static;

# Documentation browser under "/perldoc"
plugin 'PODRenderer';

my $static = Mojolicious::Static->new;

push @{$static->paths}, '/my/path;

Any Ideas?

Upvotes: 2

Views: 1252

Answers (2)

Joel Berger
Joel Berger

Reputation: 20280

You may add an absolute path as you do in your answer:

push @{app->static->paths}, '/my/abs/path';

you may also add a path relative to your app's home folder (this is how the default is setup):

push @{app->static->paths}, app->home->rel_dir('my/rel/path');

The default is to have a folder called public in your app's home path. If you do this, the app will use it out-of-the-box. Read more here.

Upvotes: 4

shaneburgess
shaneburgess

Reputation: 15912

This works:

my $static = app->static();

push @{$static->paths}, '/my/path';

Upvotes: 3

Related Questions