| 1 | package HTTP::Engine::Role::Interface; | ||||||||||||||||||||||||||||
| 2 | 28 | ▶ | use Any::Moose '::Role'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 28 | ▶ | use HTTP::Engine::Types::Core qw(Handler); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 28 | ▶ | use HTTP::Engine::ResponseFinalizer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 28 | requires 'run'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 28 | has request_handler => ( | |||||||||||||||||||||||||||
| 9 | is => 'rw', | ||||||||||||||||||||||||||||
| 10 | isa => Handler, | ||||||||||||||||||||||||||||
| 11 | coerce => 1, | ||||||||||||||||||||||||||||
| 12 | required => 1, | ||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # for PSGI streaming response | ||||||||||||||||||||||||||||
| 16 | # using HTTP::Engine::ResponseFinalizer | ||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub can_has_streaming { 0 } | ||||||||||||||||||||||||||
|
Subroutine
can_has_streaming: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 39 | ▶ | sub handle_request { | ||||||||||||||||||||||||||
|
Subroutine
handle_request: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 39 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 39 | my $req = HTTP::Engine::Request->new( | |||||||||||||||||||||||||||
| 23 | request_builder => $self->request_builder, | ||||||||||||||||||||||||||||
| 24 | %args, | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 39 | my $res; | |||||||||||||||||||||||||||
| 28 | 39 | eval { | |||||||||||||||||||||||||||
| 29 | 39 | $res = $self->request_handler->($req); | |||||||||||||||||||||||||||
| 30 | 38 | ▶ | unless ( Scalar::Util::blessed($res) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($res) and $res->isa("HTTP::Engine::Response")
MC/DC100%2/2
builtin::blessed($res) and $res->isa("HTTP::Engine::Response")
builtin::blessed($res)
$res->isa("HTTP::Engine::Response")
Truth table100%3/3
A and B
A= builtin::blessed($res)B= $res->isa("HTTP::Engine::Response")
| |||||||||||||||||||||||||||||
| 31 | && $res->isa('HTTP::Engine::Response') ) | ||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 9 | die "You should return instance of HTTP::Engine::Response."; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||
| 36 | 39 | ▶ | if ( my $e = $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 10 | print STDERR $e; | |||||||||||||||||||||||||||
| 38 | 10 | $res = HTTP::Engine::Response->new( | |||||||||||||||||||||||||||
| 39 | status => 500, | ||||||||||||||||||||||||||||
| 40 | body => 'internal server error', | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 39 | HTTP::Engine::ResponseFinalizer->finalize( $req => $res => $self ); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 37 | return $self->response_writer->finalize( $req => $res ); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 28 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||