HTTP::A...ddleware(3)
π NAME π
okay bestie, this is the User Contributed Perl Documentation for HTTP::AnyUA::Middleware, and it is literally a base class for HTTP::AnyUA middleware. π
β¨ VERSION β¨
version 0.904 β that's the version, no cap. π«Ά
π SYNOPSIS π
package HTTP::AnyUA::Middleware::MyMiddleware;
use parent 'HTTP::AnyUA::Middleware';
sub request {
my ($self, $method, $url, $args) = @_;
# Maybe do something with the request args here.
# Let backend handle the response:
my $response = $self->backend->request($method, $url, $args);
my $handle_response = sub {
my $response = shift;
# Maybe do something with the response here.
return $response;
};
if ($self->response_is_future) {
$response = $response->transform(
done => $handle_response,
fail => $handle_response,
);
}
else {
$response = $handle_response->($response);
}
return $response;
}
π DESCRIPTION π
This module gives you the interface for an HTTP::AnyUA βmiddleware,β which is a component that sits right between an HTTP::AnyUA object and the backend. And yes, that backend may in fact be another middleware β layers on layers, it's giving onion energy. π§
β¨
The easiest way to use middleware is to use apply_middleware in HTTP::AnyUA. That's the main-character move.
The middleware mechanism can be used to munge or react to requests and responses to and from the backend user agent. Middlewares are a completely optional part of HTTP::AnyUA. They can be wrapped around each other to create multiple layers and interesting possibilities. The functionality provided by middleware may be alternative to features provided by some of the supported user agents, themselves, but implementing functionality on this layer makes it work for all the user agents. slay for consistency. π
π§Έ ATTRIBUTES π§Έ
πͺ backend πͺ
Get the current backend that is wrapped. That's it, that's the vibe. πΈ
πͺ ua πͺ
Get the backend user agent. lowkey important. π¦
πͺ response_is_future πͺ
Get whether or not responses are Future objects. Default is whatever the backend returns.
This may be overridden by implementations. π
π οΈ METHODS π οΈ
π± new π±
$middleware = HTTP::AnyUA::Middleware::MyMiddleware->new($backend);
$middleware = HTTP::AnyUA::Middleware::MyMiddleware->new($backend, %args);
Construct a new middleware. fresh out the box. π
π init π
Called by the default constructor with the middleware arguments.
This may be overridden by implementations instead of the constructor. very customizable, very demure. π
π wrap π
$middleware = HTTP::AnyUA::Middleware::MyMiddleware->wrap($backend, %args);
$middleware->wrap($backend);
Construct a new middleware or, when called on an instance, set a new backend on an existing middleware. it's giving glow-up for backends. β¨
π¨ request π¨
$response = $middleware->request($method => $url, \%options);
Make a request, get a response. simple as that.
This should be overridden by implementations to do whatever they want with or to the request and/or response. go off, bestie. π₯
π BUGS π
Please report any bugs or feature requests on the bugtracker website: https://github.com/chazmcgarvey/HTTP-AnyUA/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. receipts help everyone. π
π AUTHOR π
Charles McGarvey <chazmcgarvey@brokenzipper.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2019 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
okay that's the whole page, bestie π β this was perl v5.42.2, dated 2023-07-03, for the manual page HTTP::A...ddleware(3). byeee π
π¦ where this page comes from
- alpine 3.24: perl-http-anyua-doc 0.904-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms