blib/lib/Dancer2/Core/DSL.pm

filter: Statementstmt 71.0% 145 / 204 Branchbran 54.1% 26 / 48 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 78.2% 72 / 92 Podpod 2.4% 2 / 81 totaltotal 56.8% 246 / 433 CC 30 SCAR 15.2
CC
30
Cov
67%
_add_postponed_plugin_hooks
30.0
content
27.5
session
7.0
CRAP 4.6
« blib/lib/Dancer2/Core/Response.pm ↑ Summary blib/lib/Dancer2/Core/Runner.pm »
1 # ABSTRACT: Dancer2's Domain Specific Language (DSL)
2  
3 package Dancer2::Core::DSL;
4 159 $Dancer2::Core::DSL::VERSION = '2.2.1';
5 159 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 159 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 159 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 159 ▶use Module::Runtime 'require_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 159 ▶use Ref::Util qw< is_arrayref is_hashref >;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 159 ▶use Dancer2::Core::Hook;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 159 ▶use Dancer2::Core::Response::Delayed;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 159 with 'Dancer2::Core::Role::DSL';
14  
15 0 ▶sub hook_aliases { +{} }
Subroutine hook_aliases: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub supported_hooks { () }
Subroutine supported_hooks: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 sub _add_postponed_plugin_hooks {
19 0 ▶ my ( $self, $postponed_hooks) = @_;
Subroutine _add_postponed_plugin_hooks: not called CC=5 SCAR=34.0
20  
21 0 $postponed_hooks = $postponed_hooks->{'plugin'};
22 0 ▶ return unless defined $postponed_hooks;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $postponed_hooks 0 0 0
23  
24 0 for my $plugin ( keys %{$postponed_hooks} ) {
25 0 for my $name ( keys %{$postponed_hooks->{$plugin} } ) {
26 0 my $hook = $postponed_hooks->{$plugin}{$name}{hook};
27 0 my $caller = $postponed_hooks->{$plugin}{$name}{caller};
28  
29 $self->has_hook($name)
30 or croak "plugin $plugin does not support the hook `$name'. ("
31 0 ▶ . join( ", ", @{$caller} ) . ")";
Branch: 1 branch
BranchTrueFalseTotal
$self->has_hook($name) or croak("plugin $plugin does not support the hook `${name}'. (" . join(", ", @{$caller;}) . ')') 0 0 0
32  
33 0 $self->add_hook($hook);
34 }
35 }
36 }
37  
38 sub dsl_keywords {
39  
40 # the flag means : 1 = is global, 0 = is not global. global means can be
41 # called from anywhere. not global means must be called from within a route
42 # handler
43 307 ▶ { any => { is_global => 1 },
Subroutine dsl_keywords: called CC=1 SCAR=0.0
Pod undocumented
44 app => { is_global => 1 },
45 captures => { is_global => 0 },
46 config => { is_global => 1 },
47 content => { is_global => 0 },
48 content_type => { is_global => 0 },
49 context => { is_global => 0 },
50 cookie => { is_global => 0 },
51 cookies => { is_global => 0 },
52 dance => { is_global => 1 },
53 dancer_app => { is_global => 1 },
54 dancer_version => { is_global => 1 },
55 dancer_major_version => { is_global => 1 },
56 debug => { is_global => 1 },
57 decode_json => { is_global => 1 },
58 del => { is_global => 1 },
59 delayed => {
60 is_global => 0, prototype => '&@',
61 },
62 dirname => { is_global => 1 },
63 done => { is_global => 0 },
64 dsl => { is_global => 1 },
65 encode_json => { is_global => 1 },
66 engine => { is_global => 1 },
67 error => { is_global => 1 },
68 false => { is_global => 1 },
69 flush => { is_global => 0 },
70 forward => { is_global => 0 },
71 from_json => { is_global => 1 },
72 from_yaml => { is_global => 1 },
73 get => { is_global => 1 },
74 halt => { is_global => 0 },
75 header => { is_global => 0 },
76 headers => { is_global => 0 },
77 hook => { is_global => 1 },
78 info => { is_global => 1 },
79 log => { is_global => 1 },
80 mime => { is_global => 1 },
81 options => { is_global => 1 },
82 param => { is_global => 0 },
83 params => { is_global => 0 },
84 query_parameters => { is_global => 0 },
85 body_parameters => { is_global => 0 },
86 route_parameters => { is_global => 0 },
87 pass => { is_global => 0 },
88 patch => { is_global => 1 },
89 path => { is_global => 1 },
90 post => { is_global => 1 },
91 prefix => { is_global => 1 },
92 prepare_app => {
93 is_global => 1, prototype => '&',
94 },
95 psgi_app => { is_global => 1 },
96 push_header => { is_global => 0 },
97 push_response_header => { is_global => 0 },
98 put => { is_global => 1 },
99 redirect => { is_global => 0 },
100 request => { is_global => 0 },
101 request_data => { is_global => 0 },
102 request_header => { is_global => 0 },
103 response => { is_global => 0 },
104 response_header => { is_global => 0 },
105 response_headers => { is_global => 0 },
106 runner => { is_global => 1 },
107 send_as => { is_global => 0 },
108 send_error => { is_global => 0 },
109 send_file => { is_global => 0 },
110 session => { is_global => 0 },
111 set => { is_global => 1 },
112 setting => { is_global => 1 },
113 splat => { is_global => 0 },
114 start => { is_global => 1 },
115 status => { is_global => 0 },
116 template => { is_global => 1 },
117 to_app => { is_global => 1 },
118 to_json => { is_global => 1 },
119 to_yaml => { is_global => 1 },
120 true => { is_global => 1 },
121 upload => { is_global => 0 },
122 uri_for => { is_global => 0 },
123 uri_for_route => { is_global => 0 },
124 var => { is_global => 0 },
125 vars => { is_global => 0 },
126 warning => { is_global => 1 },
127 };
128 }
129  
130 15 ▶sub dancer_app { shift->app }
Subroutine dancer_app: called CC=1 SCAR=0.0
Pod undocumented
131 1 ▶sub dancer_version { Dancer2->VERSION }
Subroutine dancer_version: called CC=1 SCAR=0.0
Pod undocumented
132  
133 sub dancer_major_version {
134 0 ▶ return ( split /\./, dancer_version )[0];
Subroutine dancer_major_version: not called CC=1 SCAR=6.9
Pod undocumented
135 }
136  
137 0 ▶sub log { shift->app->log( @_ ) }
Subroutine log: not called CC=1 SCAR=6.9
Pod undocumented
138 3 ▶sub debug { shift->app->log( debug => @_ ) }
Subroutine debug: called CC=1 SCAR=0.0
Pod undocumented
139 2 ▶sub info { shift->app->log( info => @_ ) }
Subroutine info: called CC=1 SCAR=0.0
Pod undocumented
140 5 ▶sub warning { shift->app->log( warning => @_ ) }
Subroutine warning: called CC=1 SCAR=0.0
Pod undocumented
141 2 ▶sub error { shift->app->log( error => @_ ) }
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
142  
143 1 ▶sub true {1}
Subroutine true: called CC=1 SCAR=0.0
Pod undocumented
144 0 ▶sub false {0}
Subroutine false: not called CC=1 SCAR=6.9
Pod undocumented
145  
146 3 ▶sub _path_obj { Path::Tiny::path(@_) }
Subroutine _path_obj: called CC=1 SCAR=0.0
147 1 ▶sub dirname { shift and _path_obj(@_)->parent->stringify }
Subroutine dirname: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
shift() and _path_obj(@_)->parent->stringify 1 0 1
148 2 ▶sub path { shift and _path_obj(@_)->stringify }
Subroutine path: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
shift() and _path_obj(@_)->stringify 2 0 2
149  
150 4 ▶sub config { shift->app->settings }
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
151  
152 10 ▶sub engine { shift->app->engine(@_) }
Subroutine engine: called CC=1 SCAR=0.0
Pod undocumented
153  
154 231 ▶sub setting { shift->app->setting(@_) }
Subroutine setting: called CC=1 SCAR=0.0
Pod documented
155  
156 215 ▶sub set { shift->setting(@_) }
Subroutine set: called CC=1 SCAR=0.0
Pod documented
157  
158 38 ▶sub template { shift->app->template(@_) }
Subroutine template: called CC=1 SCAR=0.0
Pod undocumented
159  
160 sub session {
161 162 ▶ my ( $self, $key, $value ) = @_;
Subroutine session: called CC=7 SCAR=19.5
Pod undocumented
162  
163 # shortcut reads if no session exists, so we don't
164 # instantiate sessions for no reason
165 162 ▶ if ( @_ == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) 71 91 162
166 71 ▶ return unless $self->app->has_session;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->app->has_session 15 56 71
167 }
168  
169 147 ▶ my $session = $self->app->session
Condition33%1/3
$self->app->session || croak('No session available, a session engine needs to be set')
l!l&&r!l&&!r
14700
MC/DC0%0/2
$self->app->session || croak('No session available, a session engine needs to be set')
$self->app->session croak('No session available, a session engine needs to be set')
Truth table33%1/3
A || B
A= $self->app->sessionB= croak('No session available, a session engine needs to be set')
ABresult
1X1
011
000
170 || croak "No session available, a session engine needs to be set";
171  
172 147 $self->app->setup_session;
173  
174 # return the session object if no key
175 147 ▶ @_ == 1 and return $session;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 and return $session 18 129 147
176  
177 # read if a key is provided
178 129 ▶ @_ == 2 and return $session->read($key);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 and return $session->read($key) 56 73 129
179  
180  
181 # write to the session or delete if value is undef
182 73 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 64 9 73
183 64 $session->write( $key => $value );
184 }
185 else {
186 9 $session->delete($key);
187 }
188 }
189  
190 11 ▶sub send_as { shift->app->send_as(@_) }
Subroutine send_as: called CC=1 SCAR=0.0
Pod undocumented
191  
192 20 ▶sub send_error { shift->app->send_error(@_) }
Subroutine send_error: called CC=1 SCAR=0.0
Pod undocumented
193  
194 24 ▶sub send_file { shift->app->send_file(@_) }
Subroutine send_file: called CC=1 SCAR=0.0
Pod undocumented
195  
196 #
197 # route handlers & friends
198 #
199  
200 sub hook {
201 104 ▶ my ( $self, $name, $code ) = @_;
Subroutine hook: called CC=1 SCAR=0.0
Pod undocumented
202 104 $self->app->add_hook(
203 Dancer2::Core::Hook->new( name => $name, code => $code ) );
204 }
205  
206 sub prefix {
207 4 ▶ my $app = shift->app;
Subroutine prefix: called CC=2 SCAR=6.9
Pod undocumented
208 4 ▶ @_ == 1
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 3 1 4
209 ? $app->prefix(@_)
210 : $app->lexical_prefix(@_);
211 }
212  
213 9 ▶sub halt { shift->app->halt(@_) }
Subroutine halt: called CC=1 SCAR=0.0
Pod undocumented
214  
215 2 ▶sub del { shift->_normalize_route( [qw/delete /], @_ ) }
Subroutine del: called CC=1 SCAR=0.0
Pod undocumented
216 383 ▶sub get { shift->_normalize_route( [qw/get head/], @_ ) }
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
217 1 ▶sub options { shift->_normalize_route( [qw/options /], @_ ) }
Subroutine options: called CC=1 SCAR=0.0
Pod undocumented
218 3 ▶sub patch { shift->_normalize_route( [qw/patch /], @_ ) }
Subroutine patch: called CC=1 SCAR=0.0
Pod undocumented
219 43 ▶sub post { shift->_normalize_route( [qw/post /], @_ ) }
Subroutine post: called CC=1 SCAR=0.0
Pod undocumented
220 4 ▶sub put { shift->_normalize_route( [qw/put /], @_ ) }
Subroutine put: called CC=1 SCAR=0.0
Pod undocumented
221  
222 2 ▶sub prepare_app { push @{ shift->app->prep_apps }, @_ }
Subroutine prepare_app: called CC=1 SCAR=0.0
Pod undocumented
223  
224 sub any {
225 7 ▶ my $self = shift;
Subroutine any: called CC=3 SCAR=11.0
Pod undocumented
226  
227 # If they've supplied their own list of methods,
228 # expand del, otherwise give them the default list.
229 7 ▶ if ( is_arrayref($_[0]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_arrayref($_[0])) { } 3 4 7
230 3 s/^del$/delete/ for @{ $_[0] };
231 }
232 else {
233 4 unshift @_, [qw/delete get head options patch post put/];
234 }
235  
236 7 $self->_normalize_route(@_);
237 }
238  
239 sub _normalize_route {
240 443 ▶ my $app = shift->app;
Subroutine _normalize_route: called CC=5 SCAR=16.3
241 443 my $methods = shift;
242 443 my %args;
243  
244 # Options are optional, try to deduce their presence from arg length.
245 443 ▶ if ( @_ == 4 ) {
Branch: 3 branches
BranchTrueFalseTotal
if (@_ == 4) { } 3 440 443
elsif (@_ == 2) { } 429 11 440
elsif (@_ == 3) { } 11 0 11
246 # @_ = ( NAME, REGEXP, OPTIONS, CODE )
247 # get 'foo', '/foo', { 'user_agent' => '...' }, sub {...}
248 3 @args{qw<name regexp options code>} = @_;
249 } elsif ( @_ == 2 ) {
250 # @_ = ( REGEXP, CODE )
251 # get '/foo', sub {...}
252 429 @args{qw<regexp code>} = @_;
253 } elsif ( @_ == 3 ) {
254 # @_ = ( REGEXP, OPTIONS, CODE )
255 # get '/foo', { 'user_agent' => '...' }, sub {...}
256 # @_ = ( NAME, REGEXP, CODE )
257 # get 'foo', '/foo',sub {...}
258 11 ▶ if ( is_hashref( $_[1] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_hashref($_[1])) { } 0 11 11
259 0 @args{qw<regexp options code>} = @_;
260 } else {
261 11 @args{qw<name regexp code>} = @_;
262 }
263 }
264  
265 443 return map $app->add_route( %args, method => $_ ), @{$methods};
266 }
267  
268 #
269 # Server startup
270 #
271  
272 # access to the runner singleton
273 # will be populated on-the-fly when needed
274 # this singleton contains anything needed to start the application server
275 1 ▶sub runner { Dancer2->runner }
Subroutine runner: called CC=1 SCAR=0.0
Pod undocumented
276  
277 # start the server
278 0 ▶sub start { shift->runner->start }
Subroutine start: not called CC=1 SCAR=6.9
Pod undocumented
279  
280 0 ▶sub dance { shift->start(@_) }
Subroutine dance: not called CC=1 SCAR=6.9
Pod undocumented
281  
282 sub psgi_app {
283 2 ▶ my $self = shift;
Subroutine psgi_app: called CC=1 SCAR=0.0
Pod undocumented
284  
285 2 $self->app->to_app;
286 }
287  
288 198 ▶sub to_app { shift->app->to_app }
Subroutine to_app: called CC=1 SCAR=0.0
Pod undocumented
289  
290 #
291 # Response alterations
292 #
293  
294 sub status {
295 9 ▶ $Dancer2::Core::Route::RESPONSE->status( $_[1] );
Subroutine status: called CC=1 SCAR=0.0
Pod undocumented
296 }
297  
298 sub push_header {
299 0 ▶ Carp::croak "DEPRECATED: push_header keyword. Please use the 'push_response_header' keyword instead of 'push_header'";
Subroutine push_header: not called CC=1 SCAR=6.9
Pod undocumented
300 }
301  
302 sub push_response_header {
303 0 ▶ shift;
Subroutine push_response_header: not called CC=1 SCAR=6.9
Pod undocumented
304 0 $Dancer2::Core::Route::RESPONSE->push_header(@_);
305 }
306  
307 sub header {
308 0 ▶ Carp::croak "DEPRECATED: header keyword. Please use the 'response_header' keyword instead of 'header'";
Subroutine header: not called CC=1 SCAR=6.9
Pod undocumented
309 }
310  
311 sub response_header {
312 4 ▶ shift;
Subroutine response_header: called CC=1 SCAR=0.0
Pod undocumented
313 4 $Dancer2::Core::Route::RESPONSE->header(@_);
314 }
315  
316 sub headers {
317 0 ▶ Carp::croak "DEPRECATED: headers keyword. Please use the 'response_headers' keyword instead of 'headers'";
Subroutine headers: not called CC=1 SCAR=6.9
Pod undocumented
318 }
319  
320 sub response_headers {
321 0 ▶ shift;
Subroutine response_headers: not called CC=1 SCAR=6.9
Pod undocumented
322 0 $Dancer2::Core::Route::RESPONSE->header(@_);
323 }
324  
325 sub content {
326 1 ▶ my $dsl = shift;
Subroutine content: called CC=6 SCAR=33.1
Pod undocumented
327  
328 # simple synchronous response
329 1 ▶ my $responder = $Dancer2::Core::Route::RESPONDER
Branch: 1 branch
BranchTrueFalseTotal
my $responder = $Dancer2::Core::Route::RESPONDER or croak("Cannot use content keyword outside delayed response") 1 0 1
330 or croak 'Cannot use content keyword outside delayed response';
331  
332 # flush if wasn't flushed before
333 0 ▶ if ( !$Dancer2::Core::Route::WRITER ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Dancer2::Core::Route::WRITER) 0 0 0
334 0 $Dancer2::Core::Route::WRITER = $responder->([
335 $Dancer2::Core::Route::RESPONSE->status,
336 $Dancer2::Core::Route::RESPONSE->headers_to_array,
337 ]);
338 }
339  
340 eval {
341 0 $Dancer2::Core::Route::WRITER->write(@_);
342 0 1;
343 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $Dancer2::Core::Route::WRITER->write(@_); 1 } } or do { my $error = $@ || "Zombie Error"; $Dancer2::Core::Route::ERROR_HANDLER ? &$Dancer2::Core::Route::ERROR_HANDLER($error) : $dsl->app->logger_engine->log("warning", "Error in delayed response: $error") } 0 0 0
344 0 ▶ my $error = $@ || 'Zombie Error';
Condition0%0/2
$@ || 'Zombie Error'
l!l
00
MC/DC0%0/1
$@ || 'Zombie Error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
345 0 ▶ $Dancer2::Core::Route::ERROR_HANDLER
Branch: 1 branch
BranchTrueFalseTotal
$Dancer2::Core::Route::ERROR_HANDLER ? : 0 0 0
346 ? $Dancer2::Core::Route::ERROR_HANDLER->($error)
347 : $dsl->app->logger_engine->log(
348 warning => "Error in delayed response: $error"
349 );
350 };
351 }
352  
353 sub content_type {
354 0 ▶ shift;
Subroutine content_type: not called CC=1 SCAR=6.9
Pod undocumented
355 0 $Dancer2::Core::Route::RESPONSE->content_type(@_);
356 }
357  
358 sub delayed {
359 1 ▶ my ( $dsl, $cb, @args ) = @_;
Subroutine delayed: called CC=3 SCAR=18.1
Pod undocumented
360  
361 1 ▶ @args % 2 == 0
Branch: 1 branch
BranchTrueFalseTotal
@args % 2 == 0 or croak("Arguments to delayed() keyword must be key/value pairs") 0 1 1
362 or croak 'Arguments to delayed() keyword must be key/value pairs';
363  
364 # first time, responder doesn't exist yet
365 1 my %opts = @args;
366 $Dancer2::Core::Route::RESPONDER
367 or return Dancer2::Core::Response::Delayed->new(
368 cb => $cb,
369 request => $Dancer2::Core::Route::REQUEST,
370 response => $Dancer2::Core::Route::RESPONSE,
371  
372 1 ▶ ( error_cb => $opts{'on_error'} )x!! $opts{'on_error'},
Branch: 1 branch
BranchTrueFalseTotal
$Dancer2::Core::Route::RESPONDER or return "Dancer2::Core::Response::Delayed"->new("cb", $cb, "request", $Dancer2::Core::Route::REQUEST, "response", $Dancer2::Core::Route::RESPONSE, ("error_cb", $opts{"on_error"}) x !!$opts{"on_error"}) 1 0 1
373 );
374  
375 # we're in an async request process
376 0 my $request = $Dancer2::Core::Route::REQUEST;
377 0 my $response = $Dancer2::Core::Route::RESPONSE;
378 0 my $responder = $Dancer2::Core::Route::RESPONDER;
379 0 my $writer = $Dancer2::Core::Route::WRITER;
380 0 my $handler = $Dancer2::Core::Route::ERROR_HANDLER;
381  
382 return sub {
383 0 ▶ local $Dancer2::Core::Route::REQUEST = $request;
Subroutine __ANON__: not called CC=1 SCAR=6.9
384 0 local $Dancer2::Core::Route::RESPONSE = $response;
385 0 local $Dancer2::Core::Route::RESPONDER = $responder;
386 0 local $Dancer2::Core::Route::WRITER = $writer;
387 0 local $Dancer2::Core::Route::ERROR_HANDLER = $handler;
388  
389 0 $cb->(@_);
390 0 };
391 }
392  
393 sub flush {
394 0 ▶ my $responder = $Dancer2::Core::Route::RESPONDER
Subroutine flush: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $responder = $Dancer2::Core::Route::RESPONDER or croak("flush() called outside streaming response") 0 0 0
395 or croak 'flush() called outside streaming response';
396  
397 0 my $response = $Dancer2::Core::Route::RESPONSE;
398 0 $Dancer2::Core::Route::WRITER = $responder->([
399 $response->status, $response->headers_to_array,
400 ]);
401 }
402  
403 sub done {
404 0 ▶ my $writer = $Dancer2::Core::Route::WRITER
Subroutine done: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $writer = $Dancer2::Core::Route::WRITER or croak("done() called outside streaming response") 0 0 0
405 or croak 'done() called outside streaming response';
406  
407 0 $writer->close;
408 }
409  
410 3 ▶sub pass { shift->app->pass }
Subroutine pass: called CC=1 SCAR=0.0
Pod undocumented
411  
412 #
413 # Route handler helpers
414 #
415  
416 sub context {
417 0 ▶ Carp::croak "DEPRECATED: context keyword. Please use the 'app' keyword instead of 'context'";
Subroutine context: not called CC=1 SCAR=6.9
Pod undocumented
418 }
419  
420 128 ▶sub request { $Dancer2::Core::Route::REQUEST }
Subroutine request: called CC=1 SCAR=0.0
Pod undocumented
421  
422 1 ▶sub request_header { shift; $Dancer2::Core::Route::REQUEST->headers->header(@_) }
Subroutine request_header: called CC=1 SCAR=0.0
Pod undocumented
423  
424 12 ▶sub response { $Dancer2::Core::Route::RESPONSE }
Subroutine response: called CC=1 SCAR=0.0
Pod undocumented
425  
426 2 ▶sub upload { shift; $Dancer2::Core::Route::REQUEST->upload(@_); }
Subroutine upload: called CC=1 SCAR=0.0
Pod undocumented
427  
428 2 ▶sub captures { $Dancer2::Core::Route::REQUEST->captures }
Subroutine captures: called CC=1 SCAR=0.0
Pod undocumented
429  
430 5 ▶sub uri_for { shift; $Dancer2::Core::Route::REQUEST->uri_for(@_); }
Subroutine uri_for: called CC=1 SCAR=0.0
Pod undocumented
431  
432 26 ▶sub uri_for_route { shift->app->uri_for_route(@_); }
Subroutine uri_for_route: called CC=1 SCAR=0.0
Pod undocumented
433  
434 32 ▶sub splat { $Dancer2::Core::Route::REQUEST->splat }
Subroutine splat: called CC=1 SCAR=0.0
Pod undocumented
435  
436 49 ▶sub params { shift; $Dancer2::Core::Route::REQUEST->params(@_); }
Subroutine params: called CC=1 SCAR=0.0
Pod undocumented
437  
438 6 ▶sub param { shift; $Dancer2::Core::Route::REQUEST->param(@_); }
Subroutine param: called CC=1 SCAR=0.0
Pod undocumented
439  
440 6 ▶sub query_parameters { shift; $Dancer2::Core::Route::REQUEST->query_parameters(@_); }
Subroutine query_parameters: called CC=1 SCAR=0.0
Pod undocumented
441 18 ▶sub body_parameters { shift; $Dancer2::Core::Route::REQUEST->body_parameters(@_); }
Subroutine body_parameters: called CC=1 SCAR=0.0
Pod undocumented
442 14 ▶sub route_parameters { shift; $Dancer2::Core::Route::REQUEST->route_parameters(@_); }
Subroutine route_parameters: called CC=1 SCAR=0.0
Pod undocumented
443  
444 2 ▶sub request_data { shift; $Dancer2::Core::Route::REQUEST->body_data(@_); }
Subroutine request_data: called CC=1 SCAR=0.0
Pod undocumented
445  
446 30 ▶sub redirect { shift->app->redirect(@_) }
Subroutine redirect: called CC=1 SCAR=0.0
Pod undocumented
447  
448 50 ▶sub forward { shift->app->forward(@_) }
Subroutine forward: called CC=1 SCAR=0.0
Pod undocumented
449  
450 12 ▶sub vars { $Dancer2::Core::Route::REQUEST->vars }
Subroutine vars: called CC=1 SCAR=0.0
Pod undocumented
451  
452 9 ▶sub var { shift; $Dancer2::Core::Route::REQUEST->var(@_); }
Subroutine var: called CC=1 SCAR=0.0
Pod undocumented
453  
454 0 ▶sub cookies { $Dancer2::Core::Route::REQUEST->cookies }
Subroutine cookies: not called CC=1 SCAR=6.9
Pod undocumented
455 0 ▶sub cookie { shift->app->cookie(@_) }
Subroutine cookie: not called CC=1 SCAR=6.9
Pod undocumented
456  
457 sub mime {
458 2 ▶ my $self = shift;
Subroutine mime: called CC=2 SCAR=9.2
Pod undocumented
459 2 ▶ if ( $self->app ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->app) { } 2 0 2
460 2 return $self->app->mime_type;
461 }
462 else {
463 0 my $runner = $self->runner;
464 0 $runner->mime_type->reset_to_default;
465 0 return $runner->mime_type;
466 }
467 }
468  
469 #
470 # engines
471 #
472  
473 sub from_json {
474 10 ▶ shift; # remove first element
Subroutine from_json: called CC=1 SCAR=0.0
Pod undocumented
475 10 require_module('Dancer2::Serializer::JSON');
476 10 Dancer2::Serializer::JSON::from_json(@_);
477 }
478  
479 sub to_json {
480 34 ▶ shift; # remove first element
Subroutine to_json: called CC=1 SCAR=0.0
Pod undocumented
481 34 require_module('Dancer2::Serializer::JSON');
482 34 Dancer2::Serializer::JSON::to_json(@_);
483 }
484  
485 sub decode_json {
486 1 ▶ shift; # remove first element
Subroutine decode_json: called CC=1 SCAR=0.0
Pod undocumented
487 1 require_module('Dancer2::Serializer::JSON');
488 1 Dancer2::Serializer::JSON::decode_json(@_);
489 }
490  
491 sub encode_json {
492 2 ▶ shift; # remove first element
Subroutine encode_json: called CC=1 SCAR=0.0
Pod undocumented
493 2 require_module('Dancer2::Serializer::JSON');
494 2 Dancer2::Serializer::JSON::encode_json(@_);
495 }
496  
497 sub from_yaml {
498 9 ▶ shift; # remove first element
Subroutine from_yaml: called CC=1 SCAR=0.0
Pod undocumented
499 9 require_module('Dancer2::Serializer::YAML');
500 9 Dancer2::Serializer::YAML::from_yaml(@_);
501 }
502  
503 sub to_yaml {
504 19 ▶ shift; # remove first element
Subroutine to_yaml: called CC=1 SCAR=0.0
Pod undocumented
505 19 require_module('Dancer2::Serializer::YAML');
506 19 Dancer2::Serializer::YAML::to_yaml(@_);
507 }
508  
509 159 1;
510  
511 __END__
« blib/lib/Dancer2/Core/Response.pm ↑ Summary blib/lib/Dancer2/Core/Runner.pm »