![]() |
![]()
| ![]() |
![]()
NAMEMojoX::MIME::Types - MIME Types for Mojolicious INHERITANCEMojoX::MIME::Types is a Mojo::Base SYNOPSISuse MojoX::MIME::Types; # set in Mojolicious as default $app->types(MojoX::MIME::Types->new); app->types(MojoX::MIME::Types->new); # ::Lite # basic interface translated into pure MIME::Types $types->type(foo => 'text/foo'); say $types->type('foo'); DESCRIPTION[Added to MIME::Types 2.07] This module is a drop-in replacement for Mojolicious::Types, but with a more correct handling plus a complete list of types... a huge list of types. Some methods ignore information they receive: those parameters are accepted for compatibility with the Mojolicious::Types interface, but should not contain useful information. Read the "DETAILS" below, about how to connect this module into Mojolicious and the differences you get. METHODSConstructors
example: $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); Attributes
Actions
DETAILSWhy?The Mojolicious::Types module has only very little knowledge about what is really needed to treat types correctly, and only contains a tiny list of extensions. MIME::Types tries to follow the standards very closely and contains all types found in various lists on internet. How to use with MojoliciousStart your Mojo application like this: package MyApp; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; ... $self->types(MojoX::MIME::Types->new); } If you have special options for MIME::Types::new(), then create your own MIME::Types object first: my $mt = MIME::Types->new(%opts); my $types = MojoX::MIME::Types->new(mime_types => $mt); $self->types($types); In any case, you can reach the smart MIME::Types object later as my $mt = $app->types->mimeTypes; my $mime = $mt->mimeTypeOf($filename); How to use with Mojolicious::LiteThe use in Mojolicious::Lite applications is only slightly different from above: app->types(MojoX::MIME::Types->new); my $types = app->types; Differences with Mojolicious::TypesThere are a few major difference with Mojolicious::Types:
SEE ALSOThis module is part of MIME-Types distribution version 2.28, built on April 18, 2025. Website: http://perl.overmeer.net/CPAN/ LICENSECopyrights 1999-2025 by [Mark Overmeer <mark@overmeer.net>]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
|