Neaf/X/Files.pm

filter: Statementstmt 97.0% 131 / 135 Branchbran 74.0% 40 / 54 Conditioncond 68.1% 30 / 44 MC/DCmcdc 30.4% 7 / 23 Subroutinesub 95.0% 19 / 20 Podpod 100% 9 / 9 totaltotal 82.8% 236 / 285 CC 44 SCAR 22.5
CC
44
Cov
86%
serve_file
16.8
new
15.0
list_dir
8.4
CRAP 9.4
« Neaf/Util/Container.pm ↑ Summary Neaf/Route/Main.pm »
1 package MVC::Neaf::X::Files;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 our $VERSION = '0.2901';
6  
7 =head1 NAME
8  
9 MVC::Neaf::X::Files - serve static content for Not Even A Framework.
10  
11 =head1 SYNOPSIS
12  
13 use MVC::Neaf;
14  
15 neaf static "/path/in/url" => "/local/path", %options;
16  
17 These options would go to this module's new() method described below.
18  
19 =head1 DESCRIPTION
20  
21 Serving static content in production via a perl application framework
22 is a bad idea.
23 However, forcing the user to run a separate web-server just to test
24 their CSS, JS, and images is an even worse one.
25  
26 So this module is here to fill the gap in L<MVC::Neaf>.
27  
28 =head1 METHODS
29  
30 =cut
31  
32 11 ▶use Cwd qw(abs_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 11 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 11 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 11 ▶use MVC::Neaf::Util qw(http_date canonize_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
37 11 ▶use MVC::Neaf::View::TT;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 11 ▶use parent qw(MVC::Neaf::X);
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 # Enumerate most common file types. Patches welcome.
41 11 our %ExtType = (
42 css => 'text/css',
43 gif => 'image/gif',
44 htm => 'text/html',
45 html => 'text/html',
46 jpeg => 'image/jpeg',
47 jpg => 'image/jpeg',
48 js => 'application/javascript',
49 pl => 'text/plain',
50 png => 'image/png',
51 txt => 'text/plain',
52 );
53  
54 =head2 new( %options )
55  
56 %options may include:
57  
58 =over
59  
60 =item * root - where to search for files. May point to asingle file, too.
61 (Required).
62  
63 =item * buffer - buffer size for serving files.
64 Currently this is also the size below which in-memory caching is on,
65 but this MAY change in the future.
66  
67 =item * cache_ttl - if given, files below the buffer size will be stored
68 in memory for cache_ttl seconds.
69 B<EXPERIMENTAL>. Cache API is not yet established.
70  
71 =item * in_memory = { name => [ "content", "type" ] }
72  
73 Serve some files from memory.
74 Content-type defaults to text/plain.
75  
76 B<EXPERIMENTAL>. Name and signature MAY change in the future.
77  
78 =back
79  
80 =cut
81  
82 11 my $dir_template = <<"HTML";
83 <html>
84 <head>
85 <title>Directory index of [% path | html %]</title>
86 </head>
87 <body>
88 <h1>Directory index of [% path | html %]</h1>
89 <h2>Generated on [% date | html %]</h2>
90 [% IF updir.length %]
91 <a href="[% updir | html %]">Parent directory</a>
92 [% END %]
93 <table width="100%" border="0">
94 [% FOREACH item IN list %]
95 <tr>
96 <td>[% IF item.dir %]DIR[% END %]</td>
97 <td><a href="[% path _ '/' _ item.name | url %]">[% item.name | html %]</a></td>
98 <td>[% IF !item.dir %][% item.size %][% END %]</td>
99 <td>[% item.lastmod %]</td>
100 </tr>
101 [% END # FOREACH %]
102 </table>
103 </body>
104 </html>
105 HTML
106  
107 11 my %static_options;
108 11 $static_options{$_}++ for qw(
109 root base_url in_memory
110 description buffer cache_ttl allow_dots dir_index dir_template view );
111  
112 13 ▶sub new {
Subroutine new: called CC=13 SCAR=27.1
Pod documented
113 13 my ($class, %options) = @_;
114  
115 defined $options{root}
116 13 ▶ or $class->my_croak( "option 'root' is required" );
Branch: 1 branch
BranchTrueFalseTotal
defined $options{"root"} or $class->my_croak("option 'root' is required") 13 0 13
117 ref $options{root}
118 13 ▶ and $class->my_croak( "option 'root' must be a string" );
Branch: 1 branch
BranchTrueFalseTotal
ref $options{"root"} and $class->my_croak("option 'root' must be a string") 0 13 13
119 13 ▶ $options{root} = abs_path($options{root}) || $options{root};
Condition33%1/3
abs_path($options{'root'}) || $options{'root'}
l!l&&r!l&&!r
1300
MC/DC0%0/2
abs_path($options{'root'}) || $options{'root'}
abs_path($options{'root'}) $options{'root'}
Truth table33%1/3
A || B
A= abs_path($options{'root'})B= $options{'root'}
ABresult
1X1
011
000
120  
121 13 my @extra = grep { !$static_options{$_} } keys %options;
122 13 ▶ $class->my_croak( "Unknown options @extra" )
Branch: 1 branch
BranchTrueFalseTotal
if @extra 0 13 13
123 if @extra;
124  
125 13 ▶ $options{buffer} ||= 4096;
Condition100%2/2
$options{"buffer"} ||= 4096
l!l
211
MC/DC100%1/1
$options{"buffer"} ||= 4096
$options{"buffer"}
Truth table100%2/2
A
A= $options{"buffer"}
Aresult
11
00
126 13 ▶ $options{buffer} =~ /^(\d+)$/
Branch: 1 branch
BranchTrueFalseTotal
$options{"buffer"} =~ /^(\d+)$/ or $class->my_croak("option 'buffer' must be a positive integer") 13 0 13
127 or $class->my_croak( "option 'buffer' must be a positive integer" );
128  
129 13 ▶ if ($options{dir_index}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"dir_index"}) 1 12 13
130 1 ▶ $options{view} ||= MVC::Neaf::View::TT->new;
Condition33%1/3
$options{"view"} ||= "MVC::Neaf::View::TT"->new
l!l&&r!l&&!r
010
MC/DC0%0/2
$options{"view"} ||= "MVC::Neaf::View::TT"->new
$options{"view"} "MVC::Neaf::View::TT"->new
Truth table33%1/3
A ||= B
A= $options{"view"}B= "MVC::Neaf::View::TT"->new
ABresult
1X1
011
000
131 1 ▶ $options{dir_template} ||= \$dir_template;
Condition50%1/2
$options{"dir_template"} ||= \$dir_template
l!l
01
MC/DC0%0/1
$options{"dir_template"} ||= \$dir_template
$options{"dir_template"}
Truth table50%1/2
A
A= $options{"dir_template"}
Aresult
11
00
132 };
133  
134 13 ▶ $options{base_url} = canonize_path(($options{base_url} || '/'), 1);
Condition100%2/2
$options{'base_url'} || '/'
l!l
49
MC/DC100%1/1
$options{'base_url'} || '/'
$options{'base_url'}
Truth table100%2/2
A
A= $options{'base_url'}
Aresult
11
00
135  
136 $options{description} = "Static content at $options{root}"
137 13 ▶ unless defined $options{description};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options{"description"} 13 0 13
138  
139 # Don't store files twice
140 13 my $preload = delete $options{in_memory};
141 13 my $self = $class->SUPER::new(%options);
142  
143 13 ▶ $self->preload( %$preload )
Branch: 1 branch
BranchTrueFalseTotal
if $preload 1 12 13
144 if ($preload);
145  
146 13 return $self;
147 };
148  
149 =head2 serve_file( $path )
150  
151 Create a Neaf-compatible response using given path.
152 The response is like follows:
153  
154 {
155 -content => (file content),
156 -headers => (length, name etc),
157 -type => (content-type),
158 -continue => (serve the rest of the file, if needed),
159 };
160  
161 Will C<die 404;> if file is not there.
162  
163 This MAY be used to create more fine-grained control over static files.
164  
165 B<EXPERIMENTAL>. New options MAY be added.
166  
167 =cut
168  
169 14 ▶sub serve_file {
Subroutine serve_file: called CC=16 SCAR=28.2
Pod documented
170 14 my ($self, $file) = @_;
171  
172 14 my $bufsize = $self->{buffer};
173 14 my $dir = $self->{root};
174 14 my $time = time;
175 14 my @header;
176  
177 # sanitize file path before caching
178 14 $file = canonize_path($file);
179  
180 14 ▶ if (my $data = $self->{cache_content}{$file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = $self->{"cache_content"}{$file}) 6 8 14
181 6 ▶ if ($data->[1] and $data->[1] < $time) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->[1] and $data->[1] < $time) { } 0 6 6
Condition66%2/3
$data->[1] and $data->[1] < $time
!ll&&!rl&&r
420
MC/DC0%0/2
$data->[1] and $data->[1] < $time
$data->[1] $data->[1] < $time
Truth table66%2/3
A and B
A= $data->[1]B= $data->[1] < $time
ABresult
0X0
100
111
182 0 delete $self->{cache_content}{$file};
183 }
184 else {
185 6 return $data->[0];
186 };
187 };
188  
189 # don't let unsafe paths through
190 8 ▶ $file =~ m#/\.\./# and die 404;
Branch: 1 branch
BranchTrueFalseTotal
$file =~ m[/\.\./] and die 404 0 8 8
191 $file =~ m#(^|/)\.# and die 404
192 8 ▶ unless $self->{allow_dots};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"allow_dots"} 8 0 8
Condition40%2/5
$self->{'allow_dots'} || $file =~ m[(^|/)\.] && die(404)
l!l
080
$file =~ m[(^|/)\.] and die 404
!ll
80
MC/DC0%0/2
$self->{'allow_dots'} || $file =~ m[(^|/)\.] && die(404)
$self->{'allow_dots'} $file =~ m[(^|/)\.]
Truth table0%0/3
A || B
A= $self->{'allow_dots'}B= $file =~ m[(^|/)\.]
ABresult
1X1
011
000
193  
194 # open file
195 8 my $xfile = join "", $dir, $file;
196  
197 8 ▶ if (-d $xfile) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $xfile) 1 7 8
198 return $self->list_dir( $file )
199 1 ▶ if $self->{dir_index};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"dir_index"} 1 0 1
200 0 die 404; # Sic! Don't reveal directory structure
201 };
202 7 my $ok = open (my $fd, "<", "$xfile");
203 7 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 1 6 7
204 # TODO 0.30 Warn
205 1 die 404;
206 };
207 6 binmode $fd;
208  
209 6 my $size = [stat $fd]->[7];
210 6 local $/ = \$bufsize;
211 6 my $buf = <$fd>;
212  
213 # determine type, fallback to extention
214 6 my $type;
215 6 $xfile =~ m#(?:^|/)([^\/]+?(?:\.(\w+))?)$#;
216 6 ▶ $type = $ExtType{lc $2} if defined $2; # TODO 0.40 unify with guess_type
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 6 0 6
217  
218 6 my $show_name = $1;
219 6 $show_name =~ s/[\"\x00-\x19\\]/_/g;
220  
221 6 ▶ my $disposition = ($type && $type =~ qr#^text|^image|javascript#)
Branch: 1 branch
BranchTrueFalseTotal
$type && $type =~ qr/^text|^image|javascript/ ? : 5 1 6
Condition66%2/3
$type and $type =~ qr/^text|^image|javascript/
!ll&&!rl&&r
105
MC/DC50%1/2
$type and $type =~ qr/^text|^image|javascript/
$type $type =~ qr/^text|^image|javascript/
Truth table66%2/3
A and B
A= $typeB= $type =~ qr/^text|^image|javascript/
ABresult
0X0
100
111
222 ? ''
223 : "attachment; filename=\"$show_name\"";
224 6 ▶ push @header, content_disposition => $disposition
Branch: 1 branch
BranchTrueFalseTotal
if $disposition 1 5 6
225 if $disposition;
226  
227 # return whole file if possible
228 6 ▶ if ($size < $bufsize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size < $bufsize) 5 1 6
229 5 my $ret = { -content => $buf, -type => $type, -headers => \@header };
230 5 ▶ if ($self->{cache_ttl}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"cache_ttl"}) 2 3 5
231 2 my $expires = $time + $self->{cache_ttl};
232 2 push @{ $ret->{-headers} }, expires => http_date( $expires );
233 2 $self->save_cache( $file, $expires, $ret );
234 };
235 5 return $ret;
236 };
237  
238 # If file is big, print header & first data chunk ASAP
239 # then do the rest via a second callback
240 1 push @header, content_length => $size;
241 1 ▶ my $continue = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
242 1 my $req = shift;
243  
244 1 local $/ = \$bufsize; # MUST do it again
245 1 ▶ while (<$fd>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fd)) 43 1 44
246 43 $req->write($_);
247 };
248 1 $req->close;
249 1 };
250  
251 1 return { -content => $buf, -type => $type, -continue => $continue, -headers => \@header };
252 };
253  
254 =head2 list_dir( $path )
255  
256 Create a directory index reply.
257 Used by serve_file() if dir_index given.
258  
259 As of current, indices are not cached.
260  
261 =cut
262  
263 1 ▶sub list_dir {
Subroutine list_dir: called CC=8 SCAR=21.3
Pod documented
264 1 my ($self, $dir) = @_;
265  
266 # TODO 0.30 better error handling (404 or smth)
267 1 ▶ opendir( my $fd, "$self->{root}/$dir" )
Branch: 1 branch
BranchTrueFalseTotal
opendir my $fd, qq[$self->{"root"}/$dir] or $self->my_croak("Failed to locate directory at ${dir}: $!") 1 0 1
268 or $self->my_croak( "Failed to locate directory at $dir: $!" );
269  
270 1 my @ret;
271 1 ▶ while (my $entry = readdir($fd)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = readdir $fd)) 125 1 126
272 125 $entry = decode_utf8($entry);
273 $entry =~ /^\./ and next
274 125 ▶ unless $self->{allow_dots};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"allow_dots"} 125 0 125
Condition60%3/5
$self->{'allow_dots'} || $entry =~ /^\./ && (next)
l!l&&r!l&&!r
01250
$entry =~ /^\./ and next
!ll
1232
MC/DC0%0/2
$self->{'allow_dots'} || $entry =~ /^\./ && (next)
$self->{'allow_dots'} $entry =~ /^\./
Truth table33%1/3
A || B
A= $self->{'allow_dots'}B= $entry =~ /^\./
ABresult
1X1
011
000
275  
276 123 my @stat = stat "$self->{root}/$dir/$entry";
277 123 ▶ my $isdir = -d "$self->{root}/$dir/$entry" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-d "$self->{'root'}/$dir/$entry" ? : 1 122 123
278  
279 123 push @ret, {
280 name => $entry,
281 dir => $isdir,
282 size => $stat[7],
283 lastmod => http_date( $stat[9] ),
284 };
285 };
286 1 closedir $fd;
287  
288 1 ▶ @ret = sort { $b->{dir} <=> $a->{dir} || $a->{name} cmp $b->{name} } @ret;
Condition66%2/3
$MVC::Neaf::X::Files::b->{'dir'} <=> $MVC::Neaf::X::Files::a->{'dir'} || $MVC::Neaf::X::Files::a->{'name'} cmp $MVC::Neaf::X::Files::b->{'name'}
l!l&&r!l&&!r
77020
MC/DC0%0/2
$MVC::Neaf::X::Files::b->{'dir'} <=> $MVC::Neaf::X::Files::a->{'dir'} || $MVC::Neaf::X::Files::a->{'name'} cmp $MVC::Neaf::X::Files::b->{'name'}
$MVC::Neaf::X::Files::b->{'dir'} <=> $MVC::Neaf::X::Files::a->{'dir'} $MVC::Neaf::X::Files::a->{'name'} cmp $MVC::Neaf::X::Files::b->{'name'}
Truth table66%2/3
A || B
A= $MVC::Neaf::X::Files::b->{'dir'} <=> $MVC::Neaf::X::Files::a->{'dir'}B= $MVC::Neaf::X::Files::a->{'name'} cmp $MVC::Neaf::X::Files::b->{'name'}
ABresult
1X1
011
000
289  
290 1 my $updir = dirname($dir);
291 1 ▶ $updir = '' if $updir eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $updir eq "." 1 0 1
292 return {
293 -view => $self->{view},
294 -template => $self->{dir_template},
295 list => \@ret,
296 date => http_date( time ),
297 path => $self->{base_url} . $dir,
298 1 updir => $self->{base_url} . $updir,
299 };
300 };
301  
302 =head2 preload( %files )
303  
304 Preload multiple in-memory files.
305  
306 Returns self.
307  
308 =cut
309  
310 7 ▶sub preload {
Subroutine preload: called CC=6 SCAR=17.9
Pod documented
311 7 my ($self, %files) = @_;
312  
313 7 foreach (keys %files) {
314 7 my $spec = $files{$_};
315 # guess order: png; image/png; filename.png; screw it - text
316 7 ▶ my $type = $ExtType{$spec->[1] || ''} || $spec->[1]
Condition100%10/10
$MVC::Neaf::X::Files::ExtType{$spec->[1] or ''} || $spec->[1] || $self->guess_type($_, $spec->[0]) || 'text/plain'
l!l
43
$MVC::Neaf::X::Files::ExtType{$spec->[1] or ""} or $spec->[1] or $self->guess_type($_, $spec->[0])
l!l&&r!l&&!r
223
$MVC::Neaf::X::Files::ExtType{$spec->[1] or ""} or $spec->[1]
l!l&&r!l&&!r
115
$spec->[1] || ''
l!l
25
MC/DC100%3/3
$MVC::Neaf::X::Files::ExtType{$spec->[1] or ''} || $spec->[1] || $self->guess_type($_, $spec->[0]) || 'text/plain'
$MVC::Neaf::X::Files::ExtType{$spec->[1] or ""} $spec->[1] $self->guess_type($_, $spec->[0])
MC/DC100%1/1
$spec->[1] || ''
$spec->[1]
Truth table100%4/4
A or B or C
A= $MVC::Neaf::X::Files::ExtType{$spec->[1] or ""}B= $spec->[1]C= $self->guess_type($_, $spec->[0])
ABCresult
1XX1
01X1
0011
0000
Truth table100%2/2
A
A= $spec->[1]
Aresult
11
00
317 || $self->guess_type( $_, $spec->[0] ) || 'text/plain';
318  
319 7 $self->save_cache( $_, undef, {
320 -content => $spec->[0],
321 -type => $type,
322 } );
323 };
324  
325 7 return $self;
326 };
327  
328 =head2 one_file_handler()
329  
330 Returns a simple closure that accepts a L<MVC::Neaf::Request> and
331 serves the requested path as is, relative to the X::Files objects's
332 root, or from cache.
333  
334 B<EXPERIMENTAL>. This is used internally by Neaf, name & meaning may change.
335  
336 =cut
337  
338 6 ▶sub one_file_handler {
Subroutine one_file_handler: called CC=2 SCAR=7.0
Pod documented
339 6 my $self = shift;
340  
341 3 ▶ return $self->{one_file} ||= sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
342 3 my $req = shift;
343 3 return $self->serve_file( $req->path );
344 6 ▶ };
Condition66%2/3
$self->{"one_file"} ||= sub { my $req = shift(); return $self->serve_file($req->path); }
l!l&&r!l&&!r
150
MC/DC0%0/2
$self->{"one_file"} ||= sub { my $req = shift(); return $self->serve_file($req->path); }
$self->{"one_file"} sub { my $req = shift(); return $self->serve_file($req->path); }
Truth table66%2/3
A ||= B
A= $self->{"one_file"}B= sub { my $req = shift(); return $self->serve_file($req->path); }
ABresult
1X1
011
000
345 };
346  
347 =head2 save_cache( $name, $expires, \%data )
348  
349 Save data in cache.
350  
351 $name is canonized file name.
352  
353 $expires is unix timestamp. If undef, cache forever.
354  
355 =cut
356  
357 9 ▶sub save_cache {
Subroutine save_cache: called CC=1 SCAR=0.0
Pod documented
358 9 my ($self, $name, $expires, $content) = @_;
359  
360 9 $name = canonize_path( $name );
361 9 $self->{cache_content}{$name} = [ $content, $expires ];
362  
363 9 return $self;
364 };
365  
366 =head2 guess_type( $filename, $content )
367  
368 Returns file's MIME type. As of current, content is ignored,
369 and only file extention is considered.
370  
371 =cut
372  
373 5 ▶sub guess_type {
Subroutine guess_type: called CC=2 SCAR=6.9
Pod documented
374 5 my ($self, $name, $content) = @_;
375  
376 5 ▶ return unless $name =~ /\.([a-z0-9]{1,4})$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\.([a-z0-9]{1,4})$/ 3 2 5
377 2 return $ExtType{lc $1};
378 };
379  
380  
381 =head2 make_route()
382  
383 Returns list of arguments suitable for C<neaf-E<gt>route(...)>:
384  
385 =over
386  
387 =item * base url;
388  
389 =item * handler sub;
390  
391 =item * a hash of options: path_info_regex, cache_ttl, and description.
392  
393 =back
394  
395 =cut
396  
397 4 ▶sub make_route {
Subroutine make_route: called CC=2 SCAR=7.0
Pod documented
398 4 my $self = shift;
399  
400 4 ▶ $self->my_croak("useless call in scalar/void context")
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 4 4
401 unless wantarray;
402  
403 5 ▶ my $handler = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
404 5 my $req = shift;
405  
406 5 my $file = $req->path_info();
407 5 return $self->serve_file( $file );
408 4 }; # end handler sub
409  
410 return (
411 $self->{base_url} => $handler,
412 method => ['GET', 'HEAD'],
413 path_info_regex => '.*',
414 cache_ttl => $self->{cache_ttl},
415 description => $self->{description},
416 4 );
417 };
418  
419 =head2 make_handler
420  
421 Returns a Neaf-compatible handler sub.
422  
423 B<DEPRECATED> Use make_route instead. This dies.
424  
425 =cut
426  
427 0 ▶sub make_handler {
Subroutine make_handler: not called CC=1 SCAR=6.9
Pod documented
428 0 my $self = shift;
429 0 $self->my_croak("DEPRECATED, use make_route() instead");
430 };
431  
432 =head1 LICENSE AND COPYRIGHT
433  
434 This module is part of L<MVC::Neaf> suite.
435  
436 Copyright 2016-2023 Konstantin S. Uvarin C<khedin@cpan.org>.
437  
438 This program is free software; you can redistribute it and/or modify it
439 under the terms of either: the GNU General Public License as published
440 by the Free Software Foundation; or the Artistic License.
441  
442 See L<http://dev.perl.org/licenses/> for more information.
443  
444 =cut
445  
446 11 1;
« Neaf/Util/Container.pm ↑ Summary Neaf/Route/Main.pm »