NAME
PAGI::Middleware::Timeout - Request timeout middleware
SYNOPSIS
use PAGI::Middleware::Builder;
my $app = builder {
enable 'Timeout',
timeout => 30,
on_timeout => sub {
my ($scope) = @_;
warn "Request to $scope->{path} timed out";
};
$my_app;
};
DESCRIPTION
PAGI::Middleware::Timeout enforces a maximum request duration. If the application doesn't respond within the timeout, a 504 Gateway Timeout response is sent.
CONFIGURATION
timeout (default: 30)
Timeout in seconds.
on_timeout (optional)
Callback called when timeout occurs. Receives $scope.
loop (optional)
IO::Async::Loop instance. If not provided, attempts to get current loop.
NOTES
The timeout only applies to the time before the response headers are sent. Once streaming has begun, the timeout no longer applies (to avoid cutting off partial responses).
If you need to timeout the entire request including body streaming, you'll need to implement that at the connection level in the server.
SEE ALSO
PAGI::Middleware - Base class for middleware