| 1 | package Net::RDAP::Server::Response; | ||||||||||
| 2 | # ABSTRACT: An RDAP response object. | ||||||||||
| 3 | 1 | ▶ | use base qw(HTTP::Response); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use JSON::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use vars qw($JSON); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | $JSON = JSON::XS->new->utf8->canonical->pretty->convert_blessed; | |||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 13 | 0 | my ($package, $request, $server, @args) = @_; | |||||||||
| 14 | 0 | my $self = $package->SUPER::new(@args); | |||||||||
| 15 | 0 | bless($self, $package); | |||||||||
| 16 | |||||||||||
| 17 | 0 | $self->{_request} = $request; | |||||||||
| 18 | 0 | $self->{_server} = $server; | |||||||||
| 19 | |||||||||||
| 20 | 0 | $self->header('content-type' => 'application/rdap+json'); | |||||||||
| 21 | 0 | $self->header('access-control-allow-origin' => '*'); | |||||||||
| 22 | |||||||||||
| 23 | 0 | return $self; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub request { shift->{_request} } | ||||||||
|
Subroutine
request: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub server { shift->{_server} } | ||||||||
|
Subroutine
server: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub ok { | ||||||||
|
Subroutine
ok: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 34 | 0 | $_[0]->code(200); | |||||||||
| 35 | 0 | $_[0]->message(q{OK}); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub error { | ||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 0 | my ($self, $code, $message) = @_; | |||||||||
| 41 | |||||||||||
| 42 | 0 | $self->code($code); | |||||||||
| 43 | 0 | $self->message($message); | |||||||||
| 44 | 0 | $self->content({ | |||||||||
| 45 | errorCode => $code, | ||||||||||
| 46 | title => $message, | ||||||||||
| 47 | }); | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub content { | ||||||||
|
Subroutine
content: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 52 | 0 | my $self = shift; | |||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | if (0 == scalar(@_)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 0 | return $self->SUPER::content; | |||||||||
| 56 | |||||||||||
| 57 | } else { | ||||||||||
| 58 | 0 | my $content = shift; | |||||||||
| 59 | 0 | return $self->SUPER::content($JSON->encode($content)); | |||||||||
| 60 | |||||||||||
| 61 | } | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | 1; | |||||||||
| 65 | |||||||||||
| 66 | __END__ | ||||||||||