line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
2846890
|
use strict; |
|
6
|
|
|
|
|
55
|
|
|
6
|
|
|
|
|
226
|
|
2
|
6
|
|
|
6
|
|
38
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
158
|
|
3
|
6
|
|
|
6
|
|
127
|
use 5.010001; |
|
6
|
|
|
|
|
24
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Mojolicious::Quick; |
6
|
|
|
|
|
|
|
$Mojolicious::Quick::VERSION = '0.003'; |
7
|
6
|
|
|
6
|
|
44
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
387
|
|
8
|
6
|
|
|
6
|
|
488
|
use Mojo::Base 'Mojolicious'; |
|
6
|
|
|
|
|
173605
|
|
|
6
|
|
|
|
|
40
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: A quick way of generating a simple Mojolicious app. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has rewrite_url => 1; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @HTTP_VERBS = qw/GET POST PUT DELETE PATCH OPTIONS/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
10
|
|
|
10
|
1
|
261500
|
my $class = shift; |
19
|
10
|
|
|
|
|
23
|
my $routes = shift; |
20
|
|
|
|
|
|
|
|
21
|
10
|
100
|
100
|
|
|
81
|
if ( $routes && ref $routes ne 'ARRAY' ) { |
22
|
1
|
|
|
|
|
3
|
unshift @_, $routes; |
23
|
|
|
|
|
|
|
} |
24
|
10
|
|
|
|
|
89
|
my $self = $class->SUPER::new(@_); |
25
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
149627
|
while ( my $path = shift @{$routes} ) { |
|
35
|
|
|
|
|
8169
|
|
27
|
25
|
|
|
|
|
41
|
my $action = shift @{$routes}; |
|
25
|
|
|
|
|
49
|
|
28
|
25
|
100
|
|
|
|
50
|
if ( grep { $path eq $_ } @HTTP_VERBS ) { |
|
150
|
|
|
|
|
337
|
|
29
|
18
|
|
|
|
|
44
|
my $verb = lc $path; |
30
|
|
|
|
|
|
|
|
31
|
18
|
|
|
|
|
31
|
$path = $action; |
32
|
18
|
100
|
|
|
|
41
|
if ( ref $path ) { |
33
|
12
|
|
|
|
|
19
|
my @paths; |
34
|
|
|
|
|
|
|
eval { |
35
|
12
|
|
|
|
|
41
|
@paths = @{$path}; |
|
12
|
|
|
|
|
33
|
|
36
|
12
|
|
|
|
|
33
|
1; |
37
|
12
|
50
|
|
|
|
21
|
} or do { |
38
|
0
|
|
|
|
|
0
|
my $reftype = ref $path; |
39
|
0
|
|
|
|
|
0
|
croak qq{Object of type $reftype cannot be coerced into an array}; |
40
|
|
|
|
|
|
|
}; |
41
|
12
|
|
|
|
|
29
|
while ( my $path = shift @paths ) { |
42
|
30
|
|
|
|
|
5139
|
$action = shift @paths; |
43
|
30
|
|
|
|
|
73
|
$self->routes->$verb( $path, $action ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
6
|
|
|
|
|
9
|
$action = shift @{$routes}; |
|
6
|
|
|
|
|
11
|
|
48
|
6
|
|
|
|
|
38
|
$self->routes->$verb( $path => $action ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
7
|
|
|
|
|
30
|
$self->routes->any( $path => $action ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$self->ua->on( |
57
|
|
|
|
|
|
|
start => sub { |
58
|
1
|
|
|
1
|
|
536
|
my ( $ua, $tx ) = @_; |
59
|
1
|
|
|
|
|
5
|
$ua->emit( original_request => $tx->req ); |
60
|
1
|
50
|
|
|
|
983
|
if ( $self->rewrite_url ) { |
61
|
1
|
|
|
|
|
12
|
$tx->req->url->host('')->scheme('')->port( $ua->server->url->port ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
9
|
|
|
|
|
59
|
); |
65
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
314
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |