| 1 | package Langertha::Request::HTTP; | ||
| 2 | # ABSTRACT: A HTTP Request inside of Langertha | ||
| 3 | 34 | our $VERSION = '0.502'; | |
| 4 | 34 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 34 | ▶ | use MooseX::NonMoose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 34 | extends 'HTTP::Request'; | |
| 8 | |||
| 9 | |||
| 10 | 34 | has request_source => ( | |
| 11 | is => 'ro', | ||
| 12 | does => 'Langertha::Role::HTTP', | ||
| 13 | ); | ||
| 14 | |||
| 15 | |||
| 16 | 34 | has response_call => ( | |
| 17 | is => 'ro', | ||
| 18 | isa => 'CodeRef', | ||
| 19 | ); | ||
| 20 | |||
| 21 | |||
| 22 | sub FOREIGNBUILDARGS { | ||
| 23 | 98 | ▶ | my ( $class, %args ) = @_; |
|
Subroutine
FOREIGNBUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 24 | 98 | return @{$args{http}}; | |
| 25 | } | ||
| 26 | |||
| 27 | sub BUILDARGS { | ||
| 28 | 98 | ▶ | my ( $class, %args ) = @_; |
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
documented
| |||
| 29 | 98 | delete $args{http}; | |
| 30 | 98 | return { %args }; | |
| 31 | } | ||
| 32 | |||
| 33 | 34 | __PACKAGE__->meta->make_immutable; | |
| 34 | |||
| 35 | |||
| 36 | 34 | 1; | |
| 37 | |||
| 38 | __END__ | ||
| 39 | |||
| 40 | =pod | ||
| 41 | |||
| 42 | =encoding UTF-8 | ||
| 43 | |||
| 44 | =head1 NAME | ||
| 45 | |||
| 46 | Langertha::Request::HTTP - A HTTP Request inside of Langertha | ||
| 47 | |||
| 48 | =head1 VERSION | ||
| 49 | |||
| 50 | version 0.502 | ||
| 51 | |||
| 52 | =head1 SYNOPSIS | ||
| 53 | |||
| 54 | # Created internally by Langertha::Role::HTTP | ||
| 55 | my $request = Langertha::Request::HTTP->new( | ||
| 56 | http => [ 'POST', $url, $headers, $body ], | ||
| 57 | request_source => $engine, | ||
| 58 | response_call => sub { ... }, | ||
| 59 | ); | ||
| 60 | |||
| 61 | =head1 DESCRIPTION | ||
| 62 | |||
| 63 | A subclass of L<HTTP::Request> that carries two extra pieces of Langertha | ||
| 64 | context: the engine object that created the request (C<request_source>) and | ||
| 65 | a callback to parse the HTTP response into the appropriate return value | ||
| 66 | (C<response_call>). | ||
| 67 | |||
| 68 | Constructed internally by L<Langertha::Role::HTTP/generate_http_request> and | ||
| 69 | dispatched by L<Langertha::Role::Chat>. You normally do not need to create | ||
| 70 | these directly. | ||
| 71 | |||
| 72 | =head2 request_source | ||
| 73 | |||
| 74 | The engine object that created this request. Must consume | ||
| 75 | L<Langertha::Role::HTTP>. | ||
| 76 | |||
| 77 | =head2 response_call | ||
| 78 | |||
| 79 | A CodeRef that accepts an L<HTTP::Response> and returns the parsed result | ||
| 80 | expected by the caller. Invoked by L<Langertha::Role::Chat/simple_chat> after | ||
| 81 | a successful response. | ||
| 82 | |||
| 83 | =head1 SEE ALSO | ||
| 84 | |||
| 85 | =over | ||
| 86 | |||
| 87 | =item * L<Langertha::Role::HTTP> - Creates instances of this class via C<generate_http_request> | ||
| 88 | |||
| 89 | =item * L<Langertha::Role::Chat> - Dispatches the request and calls C<response_call> | ||
| 90 | |||
| 91 | =back | ||
| 92 | |||
| 93 | =head1 SUPPORT | ||
| 94 | |||
| 95 | =head2 Issues | ||
| 96 | |||
| 97 | Please report bugs and feature requests on GitHub at | ||
| 98 | L<https://github.com/Getty/langertha/issues>. | ||
| 99 | |||
| 100 | =head2 IRC | ||
| 101 | |||
| 102 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||
| 103 | |||
| 104 | =head1 CONTRIBUTING | ||
| 105 | |||
| 106 | Contributions are welcome! Please fork the repository and submit a pull request. | ||
| 107 | |||
| 108 | =head1 AUTHOR | ||
| 109 | |||
| 110 | Torsten Raudssus <getty@cpan.org> | ||
| 111 | |||
| 112 | =head1 COPYRIGHT AND LICENSE | ||
| 113 | |||
| 114 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||
| 115 | |||
| 116 | This is free software; you can redistribute it and/or modify it under | ||
| 117 | the same terms as the Perl 5 programming language system itself. | ||
| 118 | |||
| 119 | =cut | ||