Skip to content

Mojolicious and Plack Middleware

Htbaa edited this page Feb 10, 2011 · 3 revisions

Mojolicious and Plack Middleware

I run my Mojolicious app like this:

plackup -p 3000 -R templates script/my_mojolicious_app

I wanted to enable some Plack middleware modules, so I edited script/my_mojolicious_app, and made the following changes:

  • use Plack::Builder;

  • Replace the call to Mojolicious::Command->start at the end of the file with the following:

    builder {
        enable "Deflater";
        # This is just an example (Mojolicious knows how to serve static files).
        enable "Static",
            path => sub { s!^/static/!! }, root => "public/";
        Mojolicious::Commands->start;
    };
Clone this wiki locally