Catalyst::View::Component::SubInclude::HTTP(3pm)

Catalyst::View::Component::SubInclude::HTTP3pm

Http plugin for c::v::component::subinclude

Usage

In your view class:

    package MyApp::View::TT;
    use Moose;
    extends 'Catalyst::View::TT';
    with 'Catalyst::View::Component::SubInclude';
    __PACKAGE__->config(
        subinclude_plugin => 'HTTP::GET',
        subinclude => {
            'HTTP::GET' => {
                class => 'HTTP',
                http_method => 'GET',
                ua_timeout => '10',
                uri_map => {
                    '/my/' => 'http://localhost:5000/',
                },
            },
            'HTTP::POST' => {
                class => 'HTTP',
                http_method => 'POST',
                ua_timeout => '10',
                uri_map => {
                    '/foo/' => 'http://www.foo.com/',
                },
            },
        },
    );

Then, somewhere in your templates:

    [% subinclude('/my/widget') %]
    ...
    [% subinclude_using('HTTP::POST', '/foo/path', { foo => 1 }) %]

Overview

"Catalyst::View::Component::SubInclude::HTTP" does HTTP requests (currently using LWP::UserAgent) and uses the responses to render subinclude contents.

Configuration

The configuration is passed in the "subinclude" key based on your plugin name which can be arbitrary.

class

Required just in case your plugin name differs from "HTTP".

http_method

Accepts "GET" and "POST" as values. The default one is "GET".

user_agent

This lazily builds a LWP::UserAgent obj, however you can pass a different user agent obj that implements the required API.

ua_timeout

User Agent's timeout config param. Defaults to 10 seconds.

uri_map

This expects a HashRef in order to map paths to different URLs.

base_url

Used only if "uri_map" is "undef" and defaults to "$c->request->base".

Methods

"generate_subinclude( $c, $path, $args )"

Note that $path should be the relative path.

Sponsorship

Development sponsored by Ionzero LLC <http://www.ionzero.com/>.

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8–9
  2. 10–11
  3. 12–13

Author

Wallace Reis "<[email protected]>"

From libcatalyst-view-component-subinclude-perl 0.10-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.