Cataly...e::HTTP(3pm)

πŸ“¦
version 0.10 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… Catalyst::View::Component::SubInclude::HTTP β€” the perl manual page, bestie edition

okay so hi, welcome to the Cataly...e::HTTP(3pm) page πŸ’– β€” that's a perl manual section 3pm situation, and it's literally the HTTP plugin for C::V::Component::SubInclude. Let's get into it.


✨ NAME ✨

Catalyst::View::Component::SubInclude::HTTP β€” the HTTP plugin for C::V::Component::SubInclude πŸ¦‹


🌸 SYNOPSIS 🌸

So like, in your view class, you do this:

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/',
            },
        },
    },
);

and then, somewhere in your templates, you just πŸ‘ drop these in:

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

slay. that's the whole vibe.


πŸ’œ DESCRIPTION πŸ’œ

Catalyst::View::Component::SubInclude::HTTP does HTTP requests (currently using LWP::UserAgent, iykyk) and then uses the responses to render subinclude contents. that's it, that's the job, and it does it well πŸ‘‘


πŸŽ€ CONFIGURATION πŸŽ€

the config gets passed in the subinclude key, based on your plugin name β€” and your plugin name can be literally whatever you want, it's arbitrary, main character energy ✨

  • class β€” Required, just in case your plugin name isn't HTTP. (Like, it's fine, names are hard.)
  • http_method β€” Accepts GET and POST as values. The default one is GET. πŸ™ˆ
  • user_agent β€” This lazily builds an LWP::UserAgent obj, but lowkey you can pass a different user agent obj that implements the required API. do your thing πŸ’…
  • ua_timeout β€” The User Agent's timeout config param. Defaults to 10 seconds. ⏳
  • uri_map β€” This expects a HashRef so you can map paths to different URLs. very demure, very mindful πŸ—ΊοΈ
  • base_url β€” Used only if uri_map is undef, and it defaults to $c->request->base. 🏠

⭐ METHODS ⭐

πŸ’« generate_subinclude( $c, $path, $args )

just a lil heads up bestie: $path should be the relative path. no cap, keep it relative 🫢


🌈 SEE ALSO 🌈

Catalyst::View::Component::SubInclude β€” go read it, it's the parent vibe πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Wallace Reis <wreis@cpan.org> β€” icon, legend, the moment ✨


πŸ’Έ SPONSORSHIP πŸ’Έ

Development sponsored by Ionzero LLC <http://www.ionzero.com/>. periodt πŸ’…


Copyright (c) 2010 Wallace Reis.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, babe πŸ’– it came from perl v5.34.0 and it's dated 2022-06-09 β€” shoutout to that build, she ate. mwah, go render some subincludes πŸŽ€βœ¨

πŸ“¦ where this page comes from