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.

Plugging in 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.

name (required)

The Plack::Middleware package name is specified in an array. The package name is written after Plack::Middleware::
Example:

 Auth::Basic

options (optional)

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.

key

Specify the names of available options loaded with Plack::Middleware.

value

Use direct characters to specify the value.

code

Specify with the Perl sub-routine.

handler

Specify the handlers that run Perl code.

condition (optional)

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.

apply_to (optional)

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.

Example


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
⚠️ **GitHub.com Fallback** ⚠️