/
ContentTypes.pm
43 lines (41 loc) · 1.46 KB
/
ContentTypes.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use v6.c;
class Bailador::ContentTypes {
has %.mapping = (
appcache => 'text/cache-manifest',
atom => 'application/atom+xml',
bin => 'application/octet-stream',
css => 'text/css',
gif => 'image/gif',
gz => 'application/x-gzip',
htm => 'text/html',
html => 'text/html;charset=UTF-8',
ico => 'image/x-icon',
jpeg => 'image/jpeg',
jpg => 'image/jpeg',
js => 'application/javascript',
json => 'application/json;charset=UTF-8',
mp3 => 'audio/mpeg',
mp4 => 'video/mp4',
ogg => 'audio/ogg',
ogv => 'video/ogg',
pdf => 'application/pdf',
png => 'image/png',
rss => 'application/rss+xml',
svg => 'image/svg+xml',
txt => 'text/plain;charset=UTF-8',
webm => 'video/webm',
woff => 'application/font-woff',
xml => 'application/xml',
zip => 'application/zip',
pm => 'application/x-perl',
pm6 => 'application/x-perl',
pl => 'application/x-perl',
pl6 => 'application/x-perl',
p6 => 'application/x-perl',
);
method detect-type(IO::Path $file, Str $default) returns Str {
my $ext = $file.extension.lc;
return %.mapping{$ext} if %.mapping{$ext}:exists;
return $default;
}
}