| 1 | #!perl | ||||||||||||||||||||||||||||
| 2 | #PODNAME: Raisin::API | ||||||||||||||||||||||||||||
| 3 | #ABSTACT: Provides Raisin DSL. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package Raisin::API; | ||||||||||||||||||||||||||||
| 9 | 7 | $Raisin::API::VERSION = '0.94'; | |||||||||||||||||||||||||||
| 10 | 7 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Hash::Merge qw(merge); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use Raisin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use Raisin::Entity; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | # use Raisin::Util qw(merge); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 7 | my @APP_CONF_METHODS = qw( | |||||||||||||||||||||||||||
| 20 | app | ||||||||||||||||||||||||||||
| 21 | api_default_format api_format api_version | ||||||||||||||||||||||||||||
| 22 | middleware mount plugin | ||||||||||||||||||||||||||||
| 23 | register_decoder register_encoder | ||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||
| 25 | 7 | my @APP_EXEC_METHODS = qw(new run); | |||||||||||||||||||||||||||
| 26 | 7 | my @APP_METHODS = qw(req res param include_missing session present error); | |||||||||||||||||||||||||||
| 27 | 7 | my @HOOKS_METHODS = qw(before before_validation after_validation after); | |||||||||||||||||||||||||||
| 28 | 7 | my @HTTP_METHODS = qw(del get head options patch post put); | |||||||||||||||||||||||||||
| 29 | 7 | my @ROUTES_METHODS = | |||||||||||||||||||||||||||
| 30 | qw(resource namespace route_param params requires optional group); | ||||||||||||||||||||||||||||
| 31 | 7 | my @SWAGGER_MERTHODS = qw(desc entity summary tags produces); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 7 | our @EXPORT = ( | |||||||||||||||||||||||||||
| 34 | @APP_CONF_METHODS, | ||||||||||||||||||||||||||||
| 35 | @APP_EXEC_METHODS, | ||||||||||||||||||||||||||||
| 36 | @APP_METHODS, | ||||||||||||||||||||||||||||
| 37 | @HOOKS_METHODS, | ||||||||||||||||||||||||||||
| 38 | @HTTP_METHODS, | ||||||||||||||||||||||||||||
| 39 | @ROUTES_METHODS, | ||||||||||||||||||||||||||||
| 40 | @SWAGGER_MERTHODS, | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 7 | my %SETTINGS = (); | |||||||||||||||||||||||||||
| 44 | 7 | my @NS = (''); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 7 | my $app; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 8 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 49 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 50 | 8 | $class->export_to_level(1, $class, @_); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 8 | strict->import; | |||||||||||||||||||||||||||
| 53 | 8 | warnings->import; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 8 | my $caller = caller; | |||||||||||||||||||||||||||
| 56 | 8 | ▶ | $app ||= Raisin->new(caller => $caller); | ||||||||||||||||||||||||||
|
Condition66%2/3
$app ||= "Raisin"->new("caller", $caller)
MC/DC0%0/2
$app ||= "Raisin"->new("caller", $caller)
$app
"Raisin"->new("caller", $caller)
Truth table66%2/3
A ||= B
A= $appB= "Raisin"->new("caller", $caller)
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 105 | ▶ | sub app { $app } | ||||||||||||||||||||||||||
|
Subroutine
app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||
| 62 | # Execution | ||||||||||||||||||||||||||||
| 63 | # | ||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub new { app->run } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 6 | ▶ | sub run { app->run } | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # | ||||||||||||||||||||||||||||
| 68 | # Compile | ||||||||||||||||||||||||||||
| 69 | # | ||||||||||||||||||||||||||||
| 70 | 2 | ▶ | sub mount { app->mount_package(@_) } | ||||||||||||||||||||||||||
|
Subroutine
mount: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | sub middleware { app->add_middleware(@_) } | ||||||||||||||||||||||||||
|
Subroutine
middleware: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||
| 74 | # Hooks | ||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||
| 76 | 1 | ▶ | sub before { app->add_hook('before', shift) } | ||||||||||||||||||||||||||
|
Subroutine
before: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub before_validation { app->add_hook('before_validation', shift) } | ||||||||||||||||||||||||||
|
Subroutine
before_validation: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub after_validation { app->add_hook('after_validation', shift) } | ||||||||||||||||||||||||||
|
Subroutine
after_validation: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub after { app->add_hook('after', shift) } | ||||||||||||||||||||||||||
|
Subroutine
after: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # | ||||||||||||||||||||||||||||
| 83 | # Resource | ||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||
| 85 | 67 | ▶ | sub resource { | ||||||||||||||||||||||||||
|
Subroutine
resource: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 67 | my ($name, $code, @args) = @_; | |||||||||||||||||||||||||||
| 87 | 67 | ▶ | if (scalar(@args) % 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 1 | croak "Odd-sized hash supplied to resource(). Is the previous resource missing a semicolon?"; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 66 | my %args = @args; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 66 | ▶ | if ($name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 28 | $name =~ s{^/}{}msx; | |||||||||||||||||||||||||||
| 94 | 28 | push @NS, $name; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 28 | ▶ | if ($SETTINGS{desc}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 7 | app->resource_desc($NS[-1], delete $SETTINGS{desc}); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 28 | my %prev_settings = %SETTINGS; | |||||||||||||||||||||||||||
| 101 | 28 | Hash::Merge::set_clone_behavior(undef); | |||||||||||||||||||||||||||
| 102 | 28 | %SETTINGS = %{ merge(\%SETTINGS, \%args) }; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # Going deeper | ||||||||||||||||||||||||||||
| 105 | 28 | $code->(); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 27 | pop @NS; | |||||||||||||||||||||||||||
| 108 | 27 | %SETTINGS = (); | |||||||||||||||||||||||||||
| 109 | 27 | %SETTINGS = %prev_settings; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 65 | ▶ | (join '/', @NS) || '/'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 1 | ▶ | sub namespace { resource(@_) } | ||||||||||||||||||||||||||
|
Subroutine
namespace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 9 | ▶ | sub route_param { | ||||||||||||||||||||||||||
|
Subroutine
route_param: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | 9 | my ($param, $code) = @_; | |||||||||||||||||||||||||||
| 118 | 9 | resource(":$param", $code, named => delete $SETTINGS{params}); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # | ||||||||||||||||||||||||||||
| 122 | # Serialization | ||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub register_decoder { | ||||||||||||||||||||||||||
|
Subroutine
register_decoder: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | 0 | my ($format, $class) = @_; | |||||||||||||||||||||||||||
| 126 | 0 | app->decoder->register($format => $class); | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 1 | ▶ | sub register_encoder { | ||||||||||||||||||||||||||
|
Subroutine
register_encoder: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 130 | 1 | my ($format, $class) = @_; | |||||||||||||||||||||||||||
| 131 | 1 | app->encoder->register($format => $class); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # | ||||||||||||||||||||||||||||
| 135 | # Actions | ||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||
| 137 | 4 | ▶ | sub del { _add_route('delete', @_) } | ||||||||||||||||||||||||||
|
Subroutine
del: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 138 | 18 | ▶ | sub get { _add_route('get', @_) } | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 139 | 1 | ▶ | sub head { _add_route('head', @_) } | ||||||||||||||||||||||||||
|
Subroutine
head: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 140 | 1 | ▶ | sub options { _add_route('options', @_) } | ||||||||||||||||||||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 4 | ▶ | sub patch { _add_route('patch', @_) } | ||||||||||||||||||||||||||
|
Subroutine
patch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 5 | ▶ | sub post { _add_route('post', @_) } | ||||||||||||||||||||||||||
|
Subroutine
post: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 5 | ▶ | sub put { _add_route('put', @_) } | ||||||||||||||||||||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 16 | ▶ | sub params { $SETTINGS{params} = \@_ } | ||||||||||||||||||||||||||
|
Subroutine
params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 10 | ▶ | sub requires { (requires => { name => @_ }) } | ||||||||||||||||||||||||||
|
Subroutine
requires: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 148 | 12 | ▶ | sub optional { (optional => { name => @_ }) } | ||||||||||||||||||||||||||
|
Subroutine
optional: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub group(&) { (encloses => [shift->()]) } | ||||||||||||||||||||||||||
|
Subroutine
group: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | # Swagger | ||||||||||||||||||||||||||||
| 153 | 9 | ▶ | sub desc { $SETTINGS{desc} = shift } | ||||||||||||||||||||||||||
|
Subroutine
desc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub entity { $SETTINGS{entity} = shift } | ||||||||||||||||||||||||||
|
Subroutine
entity: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 16 | ▶ | sub summary { $SETTINGS{summary} = shift } | ||||||||||||||||||||||||||
|
Subroutine
summary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 156 | 3 | ▶ | sub tags { $SETTINGS{tags} = \@_ } | ||||||||||||||||||||||||||
|
Subroutine
tags: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | 2 | ▶ | sub produces {$SETTINGS{produces} = shift } | ||||||||||||||||||||||||||
|
Subroutine
produces: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 38 | ▶ | sub _add_route { | ||||||||||||||||||||||||||
|
Subroutine
_add_route: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 160 | 38 | my @params = @_; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 38 | my $code = pop @params; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 38 | my ($method, $path) = @params; | |||||||||||||||||||||||||||
| 165 | 38 | my $r = resource(); | |||||||||||||||||||||||||||
| 166 | 38 | ▶ | if ($r eq '/' && $path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$r eq "/" and $path
MC/DC0%0/2
$r eq "/" and $path
$r eq "/"
$path
Truth table33%1/3
A and B
A= $r eq "/"B= $path
| |||||||||||||||||||||||||||||
| 167 | 0 | $path = $r . $path; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||
| 170 | 38 | ▶ | $path = $r . ($path ? "/$path" : ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | app->add_route( | ||||||||||||||||||||||||||||
| 174 | code => $code, | ||||||||||||||||||||||||||||
| 175 | method => $method, | ||||||||||||||||||||||||||||
| 176 | path => $path, | ||||||||||||||||||||||||||||
| 177 | params => delete $SETTINGS{params}, | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | desc => delete $SETTINGS{desc}, | ||||||||||||||||||||||||||||
| 180 | entity => delete $SETTINGS{entity}, | ||||||||||||||||||||||||||||
| 181 | summary => delete $SETTINGS{summary}, | ||||||||||||||||||||||||||||
| 182 | tags => delete $SETTINGS{tags}, | ||||||||||||||||||||||||||||
| 183 | produces => delete $SETTINGS{produces}, | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 38 | %SETTINGS, | |||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 38 | join '/', @NS; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | # | ||||||||||||||||||||||||||||
| 192 | # Request and Response shortcuts | ||||||||||||||||||||||||||||
| 193 | # | ||||||||||||||||||||||||||||
| 194 | 1 | ▶ | sub req { app->req } | ||||||||||||||||||||||||||
|
Subroutine
req: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 195 | 5 | ▶ | sub res { app->res } | ||||||||||||||||||||||||||
|
Subroutine
res: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub param { | ||||||||||||||||||||||||||
|
Subroutine
param: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 197 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 198 | 0 | ▶ | return app->req->raisin_parameters->{$name} if $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | app->req->raisin_parameters; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub session { app->session(@_) } | ||||||||||||||||||||||||||
|
Subroutine
session: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 2 | ▶ | sub present { | ||||||||||||||||||||||||||
|
Subroutine
present: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 2 | my ($key, $data, %params) = @_; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 2 | ▶ | my $entity = $params{with} || 'Raisin::Entity::Default'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$params{'with'} || 'Raisin::Entity::Default'
MC/DC100%1/1
$params{'with'} || 'Raisin::Entity::Default'
$params{'with'}
Truth table100%2/2
A
A= $params{'with'}
| |||||||||||||||||||||||||||||
| 207 | 2 | my $value = Raisin::Entity->compile($entity, $data); | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 2 | ▶ | my $body = res->body || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
res()->body || {}
MC/DC0%0/1
res()->body || {}
res()->body
Truth table50%1/2
A
A= res()->body
| |||||||||||||||||||||||||||||
| 210 | 2 | my $representation = { $key => $value, %$body }; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 2 | res->body($representation); | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 2 | return; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub include_missing { | ||||||||||||||||||||||||||
|
Subroutine
include_missing: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 218 | 0 | my $p = shift; | |||||||||||||||||||||||||||
| 219 | # TODO: replace app->req->{'raisin.declared'}, if it is possible, to app->route->params | ||||||||||||||||||||||||||||
| 220 | 0 | my %pp = map { $_->name, $p->{ $_->name } } @{ app->req->{'raisin.declared'} }; | |||||||||||||||||||||||||||
| 221 | 0 | \%pp; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | # | ||||||||||||||||||||||||||||
| 225 | # System | ||||||||||||||||||||||||||||
| 226 | # | ||||||||||||||||||||||||||||
| 227 | 3 | ▶ | sub plugin { app->load_plugin(@_) } | ||||||||||||||||||||||||||
|
Subroutine
plugin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 3 | ▶ | sub api_default_format { app->default_format(@_) } | ||||||||||||||||||||||||||
|
Subroutine
api_default_format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 230 | 3 | ▶ | sub api_format { app->format(@_) } | ||||||||||||||||||||||||||
|
Subroutine
api_format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # TODO: | ||||||||||||||||||||||||||||
| 233 | # prepend a resource with a version number | ||||||||||||||||||||||||||||
| 234 | # http://example.com/api/1 | ||||||||||||||||||||||||||||
| 235 | 2 | ▶ | sub api_version { app->api_version(@_) } | ||||||||||||||||||||||||||
|
Subroutine
api_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||
| 238 | # Render | ||||||||||||||||||||||||||||
| 239 | # | ||||||||||||||||||||||||||||
| 240 | 1 | ▶ | sub error { | ||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 241 | 1 | my ($code, $message) = @_; | |||||||||||||||||||||||||||
| 242 | 1 | app->res->status($code); | |||||||||||||||||||||||||||
| 243 | 1 | app->res->body($message); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 7 | 1; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | __END__ | ||||||||||||||||||||||||||||