Create the 'type' handler for Mojolicious. When you do not specify your own MIME::Type object ($mime_type), it will be instantanted for you. You create one yourself when you would like to pass some parameter to the object constructor.
Option | Default |
---|---|
mime_types | <created internally> |
types | undef |
$app->types(MojoX::MIME::Types->new); # when you need to pass options to MIME::Types->new my $mt = MIME::Types->new(%opts); my $types = MojoX::MIME::Types->new(mime_types => $mt); $app->types($types);
Returns the internal mime types object.
In Mojolicious::Types, this attribute exposes the internal administration of types, offering to change it with using a clean abstract interface. That interface mistake bites now we have more complex internals.
Avoid this method! The returned HASH is expensive to construct,
changes passed via %table
are ignored: MIME::Types is very complete!
Returns a list of filename extensions. The $accept header in HTTP can
contain multiple types, with a priority indication ('q' attributes).
The returned list contains a list with extensions, the extensions related
to the highest priority type first. The $prio
-flag is ignored.
See MIME::Types::httpAccept().
This detect() function is not the correct approach for the Accept header: the "Accept" may contain wildcards ('*') in types for globbing, which does not produce extensions. Better use MIME::Types::httpAcceptBest() or MIME::Types::httpAcceptSelect().
my $exts = $types->detect('application/json;q=9'); my $exts = $types->detect('text/html, application/json;q=9');
Returns the first type name for an extension $ext, unless you specify type names.
When a single $type or an ARRAY of @types are specified, the $self
object is returned. Nothing is done with the provided info.