HTTP::Engine::Compat::Context - Context object


HTTP-Engine-Compat documentation Contained in the HTTP-Engine-Compat distribution.

Index


Code Index:

NAME

Top

HTTP::Engine::Compat::Context - Context object

SYNOPSIS

Top

    my $c = shift;

DESCRIPTION

Top

Kazuhiro Osawa and HTTP::Engine Authors.

ATTRIBUTES

Top

req
    $c->req

The instance of the HTTP::Engine::Request.

res
    $c->res

The instance of the HTTP::Engine::Response.

SEE ALSO

Top

HTTP::Engine


HTTP-Engine-Compat documentation Contained in the HTTP-Engine-Compat distribution.

package HTTP::Engine::Compat::Context;
use Moose;
use HTTP::Engine::Request;
use HTTP::Engine::Response;

has req => (
    is       => 'rw',
    isa      => 'HTTP::Engine::Request',
    required => 1,
    default  => sub {
        my $self = shift;
        HTTP::Engine::Request->new(
            context     => $self,
            request_builder => HTTP::Engine::RequestBuilder->new(),
            _connection => {
                input_handle  => \*STDIN,
                output_handle => \*STDOUT,
                env           => \%ENV,
            },
        );
    },
    trigger => sub {
        my ( $self, $new_req ) = @_;
        $new_req->context($self);
    },
);

has res => (
    is       => 'rw',
    isa      => 'HTTP::Engine::Response',
    required => 1,
    default  => sub {
        HTTP::Engine::Response->new;
    },
);

# shortcut.
*request  = \&req;
*response = \&res;

__PACKAGE__->meta->make_immutable;

1;
__END__