Running Plack::Middleware in Movable Type - movabletype/Documentation GitHub Wiki
Plack::Middleware, included with Movable Type 5.2.4., can be used to upload a variety of processes to applications built with PSGI. This document explains how to plug-in Plack::Middleware to Movable Type running on a PSGI/Plack environment.
This document does not cover how to install or use Plack::Middleware.
In order to plug-in Plack::Middleware, you will need to enter certain Plack::Middleware information under the registry plack_middlewares in the plug-in config.yaml. Items that must or can be specified are listed below.
The Plack::Middleware package name is specified in an array. The package name is written after Plack::Middleware::
Example:
Auth::Basic
If a pass option is available for Plack::Middleware, the option key plus value or handler pairs must be specified in an array. There are four ways you can specify the key value, however one method must be paired with the key.
Specify the names of available options loaded with Plack::Middleware.
Use direct characters to specify the value.
Specify with the Perl sub-routine.
Specify the handlers that run Perl code.
It’s possible to specify the handler for the Perl sub-routine or code that manages execution of Plack::Middleware. If 0 is returned, Plack::Middleware will not load.
Specify the Movable Type applications that are allowed to use Plack::Middleware. Movable Type applications are set by adding the key name of each application in registry applications.
(Example: cms, tb, comments, new_search, etc.)
If apply_to is left unspecified, or if all is specified, then all Movable Type applications will be allowed to run Plack::Middleware.
plack_middlewares:
- name: Sample::Middleware
options:
- key: foo
value: any value
- key: bar
code: >
sub {
my $val;
# do something
return $val;
}
- key: baz
handler: Your::Plugin::hdlr_baz
condition: Your::Plugin::condition
apply_to:
- cms
- new_search