1Dancer2::Core::MIME(3)User Contributed Perl DocumentationDancer2::Core::MIME(3)
2
3
4
6 Dancer2::Core::MIME - Class to ease manipulation of MIME types
7
9 version 0.300004
10
12 use Dancer2::Core::MIME;
13
14 my $mime = Dancer2::Core::MIME->new();
15
16 # get mime type for an alias
17 my $type = $mime->for_name('css');
18
19 # set a new mime type
20 my $type = $mime->add_type( foo => 'text/foo' );
21
22 # set a mime type alias
23 my $alias = $mime->add_alias( f => 'foo' );
24
25 # get mime type for a file (based on extension)
26 my $file = $mime->for_file( "foo.bar" );
27
28 # set the $thing into a content $type.
29 my $type = $mime->name_or_type($thing);
30
31 # get current defined default mime type
32 my $type = $mime->default;
33
34 # set the default mime type using config.yml
35 # or using the set keyword
36 set default_mime_type => 'text/plain';
37
39 Dancer2::Core::MIME is a thin wrapper around MIME::Types providing
40 helpful methods for MIME handling.
41
43 custom_types
44 Custom user-defined MIME types that are added the with "add_type".
45
46 default
47 Default MIME type defined by MIME::Types, set to: application/data.
48
50 reset_default
51 This method resets "mime_type" to the default type.
52
53 add_type
54 This method adds the new MIME type.
55
56 add_alias
57 The "add_alias" sets a MIME type alias.
58
59 for_name
60 The method "for_name" gets MIME type for an alias.
61
62 for_file
63 This method gets MIME type for a file based on extension.
64
65 name_or_type
66 This method sets the customized MIME name or default MIME type into a
67 content type.
68
70 Dancer Core Developers
71
73 This software is copyright (c) 2020 by Alexis Sukrieh.
74
75 This is free software; you can redistribute it and/or modify it under
76 the same terms as the Perl 5 programming language system itself.
77
78
79
80perl v5.32.0 2020-07-28 Dancer2::Core::MIME(3)