App-PAIA
view release on metacpan or search on metacpan
lib/App/PAIA/Tester.pm view on Meta::CPAN
sub paia_response(@) { ## no critic
$PSGI_RESPONSE = $DEFAULT_PSGI;
if (ref $_[0] and reftype $_[0] eq 'ARRAY') {
$PSGI_RESPONSE = shift;
} else {
$PSGI_RESPONSE = $DEFAULT_PSGI;
$PSGI_RESPONSE->[0] = $_[0] =~ /^\d+/ ? shift : 200;
$PSGI_RESPONSE->[1] = shift if ref $_[0] and reftype $_[0] eq 'ARRAY' and @_ > 1;
my $content = shift;
if (reftype $content eq 'HASH') {
push @{$PSGI_RESPONSE->[1]}, 'Content-type', 'application/json; charset=UTF-8';
$PSGI_RESPONSE->[2] = [ encode_json($content) ];
} elsif (reftype $_[1] eq 'ARRAY') {
$PSGI_RESPONSE->[2] = $content;
} else {
$PSGI_RESPONSE->[2] = [$content];
}
}
no warnings;
*HTTP::Tiny::request = \&mock_http;
( run in 0.323 second using v1.01-cache-2.11-cpan-0d8aa00de5b )