NAME
    Plack::Middleware::Timeout

SYNOPSIS
        my $app = sub { ... };

        Plack::Middleeare::Timeout->wrap(
            $app,
            timeout  => sub { ... } || 60,
            # optional callback to set the custom response 
            response => sub {
                my ($response_obj,$execution_time) = @_;

                $response_obj->code(HTTP_REQUEST_TIMEOUT);
                $response_obj->body( encode_json({
                    timeout => 1,
                    other_info => {...},
                }));

                return $plack_response;
            }
        );

DESCRIPTION
    Timeout any plack requests at an arbitrary time.

PARAMETERS
    timeout
        Determines how we're going to get the timeout value, either subref
        returning a value or any value accepted by subroutine defined in
        Time::HiRes::alarm, default 120 seconds.

    response
        Optional subroutine that receives two parameters, a Plack::Response
        object that we can further modify to fit our needs, if none is
        provided the middleware resolves to emitting a warning:

            'Terminated request for uri '%s' due to timeout (%ds)'

    soft_timeout
        Same as timeout, except this value will be checked after the call to
        the app has completed. See also "on_soft_timeout" below.

    on_soft_timeout
        optional coderef that'll get executed when we established, that time
        required to serve the response was longer than a value provided in the
        soft_timeout parameter. If soft_timeout is set but no on_soft_timeout
        coderef is provided, we're going to issue a warning as follows; the
        response will be returned as normal.

            'Soft timeout reached for uri '%s' (soft timeout: %ds) request
            took %ds'

AUTHOR
    Tomasz Czepiel <tjmc@cpan.org>

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

