| 1 | package HTTP::Engine::Compat::Context; | ||
| 2 | use Moose; | ||
| 3 | use HTTP::Engine::Request; | ||
| 4 | use HTTP::Engine::Response; | ||
| 5 | |||
| 6 | has req => ( | ||
| 7 | is => 'rw', | ||
| 8 | isa => 'HTTP::Engine::Request', | ||
| 9 | required => 1, | ||
| 10 | default => sub { | ||
| 11 | my $self = shift; | ||
| 12 | HTTP::Engine::Request->new( | ||
| 13 | context => $self, | ||
| 14 | request_builder => HTTP::Engine::RequestBuilder->new(), | ||
| 15 | _connection => { | ||
| 16 | input_handle => \*STDIN, | ||
| 17 | output_handle => \*STDOUT, | ||
| 18 | env => \%ENV, | ||
| 19 | }, | ||
| 20 | ); | ||
| 21 | }, | ||
| 22 | trigger => sub { | ||
| 23 | my ( $self, $new_req ) = @_; | ||
| 24 | $new_req->context($self); | ||
| 25 | }, | ||
| 26 | ); | ||
| 27 | |||
| 28 | has res => ( | ||
| 29 | is => 'rw', | ||
| 30 | isa => 'HTTP::Engine::Response', | ||
| 31 | required => 1, | ||
| 32 | default => sub { | ||
| 33 | HTTP::Engine::Response->new; | ||
| 34 | }, | ||
| 35 | ); | ||
| 36 | |||
| 37 | # shortcut. | ||
| 38 | *request = \&req; | ||
| 39 | *response = \&res; | ||
| 40 | |||
| 41 | __PACKAGE__->meta->make_immutable; | ||
| 42 | |||
| 43 | 1; | ||
| 44 | __END__ |