Mojolicious::Plugin::MountPSGI - Mount PSGI apps
# Mojolicious $self->plugin('MountPSGI', { '/' => 'ext/MyApp/app.psgi'}); # Mojolicious::Lite plugin 'MountPSGI', { '/' => 'ext/MyApp/app.psgi' }; # rewrite the path so the psgi app doesn't see the mount point # thus app.psgi sees / when /mount is visited plugin 'MountPSGI', { '/mount' => 'ext/MyApp/app.psgi', rewrite => 1 };
Mojolicious::Plugin::MountPSGI lets you mount any PSGI app inside a Mojolicious app. For instance you could use this to deploy your PSGI app under hypnotoad, or to include a PSGI app inside a path inside your Mojo app.
The key given is the route under which to mount the app. The value is either a PSGI application or a string which resolves to an instance via "load_psgi" in Plack::Util.
One additional option is rewrite which if set to a true value will rewrite the PATH_INFO and SCRIPT_NAME values in the env hash so that the application does not see the mount point in its request path. This uses the mechanism as described by Plack::App::URLMap.
rewrite
PATH_INFO
SCRIPT_NAME
Due to the way Mojolicious parses multipart requests, the original request body is not available to pass to the PSGI application. As a stopgap measure this plugin rebuilds the request from its parts at what is likely a huge cost in performance. There has been discussion about "adding proxying primatives" to Mojolicious which would likely be useful in resolving this performance hit.
If PLACK_ENV is not otherwise set, the "mode" in Mojolicious will be used while loading the application script and during synchronous responses. For delayed responses, the plugin cannot ensure that it will be set. Applications should fetch their PLACK_ENV before requesting a delayed response and manage it appropriately.
PLACK_ENV
Mojolicious::Plugin::MountPSGI inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register plugin in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
Joel Berger (jberger)
Peter Valdemar Mørch (pmorch)
Graham Knop (haarg)
Most of this module was assembled from the Mojo mount plugin and the Mojolicious-Plugin-PlackMiddleware plugin. Copyright on that code belongs to the authors.
The remainder is (C) 2011-2015 Marcus Ramberg and the /CONTRIBUTORS above.
/CONTRIBUTORS
Licensed under the same terms as Perl itself.
To install Mojolicious::Plugin::MountPSGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::MountPSGI
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::MountPSGI
For more information on module installation, please visit the detailed CPAN module installation guide.