line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Web interface to a Pinto repository |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Server; |
4
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
1704424
|
use Moose; |
|
13
|
|
|
|
|
4880909
|
|
|
13
|
|
|
|
|
88
|
|
6
|
13
|
|
|
13
|
|
89183
|
use MooseX::ClassAttribute; |
|
13
|
|
|
|
|
998846
|
|
|
13
|
|
|
|
|
52
|
|
7
|
13
|
|
|
13
|
|
3588269
|
use MooseX::Types::Moose qw(Int HashRef); |
|
13
|
|
|
|
|
577070
|
|
|
13
|
|
|
|
|
114
|
|
8
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
|
55781
|
use Carp; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
757
|
|
10
|
13
|
|
|
13
|
|
956
|
use Path::Class; |
|
13
|
|
|
|
|
77375
|
|
|
13
|
|
|
|
|
595
|
|
11
|
13
|
|
|
13
|
|
59
|
use Class::Load; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
457
|
|
12
|
13
|
|
|
13
|
|
65
|
use Scalar::Util qw(blessed); |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
535
|
|
13
|
13
|
|
|
13
|
|
4276
|
use IO::Interactive qw(is_interactive); |
|
13
|
|
|
|
|
9344
|
|
|
13
|
|
|
|
|
79
|
|
14
|
13
|
|
|
13
|
|
3476
|
use Plack::Middleware::Auth::Basic; |
|
13
|
|
|
|
|
66671
|
|
|
13
|
|
|
|
|
382
|
|
15
|
|
|
|
|
|
|
|
16
|
13
|
|
|
13
|
|
3602
|
use Pinto::Types qw(Dir); |
|
13
|
|
|
|
|
92
|
|
|
13
|
|
|
|
|
120
|
|
17
|
13
|
|
|
13
|
|
111148
|
use Pinto::Constants qw(:server); |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
1216
|
|
18
|
13
|
|
|
13
|
|
6967
|
use Pinto::Server::Router; |
|
13
|
|
|
|
|
59
|
|
|
13
|
|
|
|
|
556
|
|
19
|
13
|
|
|
13
|
|
7870
|
use Pinto::Repository; |
|
13
|
|
|
|
|
57
|
|
|
13
|
|
|
|
|
5193
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.14'; # VERSION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has root => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => Dir, |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has auth => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => HashRef, |
39
|
|
|
|
|
|
|
traits => ['Hash'], |
40
|
|
|
|
|
|
|
handles => { auth_options => 'elements' }, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has router => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => 'Pinto::Server::Router', |
47
|
|
|
|
|
|
|
default => sub { Pinto::Server::Router->new }, |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
class_has default_port => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => Int, |
55
|
|
|
|
|
|
|
default => $PINTO_SERVER_DEFAULT_PORT, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub BUILD { |
61
|
13
|
|
|
13
|
0
|
27366
|
my ($self) = @_; |
62
|
|
|
|
|
|
|
|
63
|
13
|
|
|
|
|
372
|
my $repo = Pinto::Repository->new( root => $self->root ); |
64
|
13
|
|
|
|
|
92
|
$repo->assert_sanity_ok; |
65
|
|
|
|
|
|
|
|
66
|
13
|
|
|
|
|
367
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub to_app { |
73
|
13
|
|
|
13
|
1
|
156
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
|
75
|
13
|
|
|
140
|
|
102
|
my $app = sub { $self->call(@_) }; |
|
140
|
|
|
|
|
2564459
|
|
76
|
|
|
|
|
|
|
|
77
|
13
|
100
|
|
|
|
403
|
if ( my %auth_options = $self->auth_options ) { |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $backend = delete $auth_options{backend} |
80
|
2
|
50
|
|
|
|
10
|
or carp 'No auth backend provided!'; |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
6
|
my $class = 'Authen::Simple::' . $backend; |
83
|
2
|
50
|
|
|
|
10
|
print "Authenticating using $class\n" if is_interactive; |
84
|
2
|
|
|
|
|
40
|
Class::Load::load_class($class); |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
21020
|
$app = Plack::Middleware::Auth::Basic->wrap( $app, authenticator => $class->new(%auth_options) ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
13
|
|
|
|
|
593
|
return $app; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub call { |
96
|
140
|
|
|
140
|
1
|
450
|
my ( $self, $env ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
140
|
|
|
|
|
4662
|
my $response = $self->router->route( $env, $self->root ); |
99
|
|
|
|
|
|
|
|
100
|
130
|
100
|
66
|
|
|
2135
|
$response = $response->finalize |
101
|
|
|
|
|
|
|
if blessed($response) && $response->can('finalize'); |
102
|
|
|
|
|
|
|
|
103
|
130
|
|
|
|
|
17870
|
return $response; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=pod |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=encoding UTF-8 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=for :stopwords Jeffrey Ryan Thalhammer |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 NAME |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Pinto::Server - Web interface to a Pinto repository |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 VERSION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
version 0.14 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 root |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The path to the root directory of your Pinto repository. The |
130
|
|
|
|
|
|
|
repository must already exist at this location. This attribute is |
131
|
|
|
|
|
|
|
required. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 auth |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The hashref of authentication options, if authentication is to be used within |
136
|
|
|
|
|
|
|
the server. One of the options must be 'backend', to specify which |
137
|
|
|
|
|
|
|
Authen::Simple:: class to use; the other key/value pairs will be passed as-is |
138
|
|
|
|
|
|
|
to the Authen::Simple class. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 router |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
An object that does the L<Pinto::Server::Handler> role. This object |
143
|
|
|
|
|
|
|
will do the work of processing the request and returning a response. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 default_port |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns the default port number that the server will listen on. This |
148
|
|
|
|
|
|
|
is a class attribute. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 METHODS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 to_app() |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns the application as a subroutine reference. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 call( $env ) |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Invokes the application with the specified environment. Returns a |
159
|
|
|
|
|
|
|
PSGI-compatible response. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
There is nothing to see here. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Look at L<pintod> if you want to start the server. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@stratopan.com> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
174
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |