Dancer::MIME(3pm)
π Dancer::MIME π
okay bestie, so this is Dancer::MIME, a manual page from the User Contributed Perl Documentation corner of the perl world β a singleton object that handles MimeTypes for you. that's the whole vibe. one object, all the mime types, no chaos. π
β¨ NAME β¨
Dancer::MIME β singleton object to handle MimeTypes. one instance, no cap, she runs the whole mime-type situation by herself. π
πΈ VERSION πΈ
version 1.3522 β that's the one, that's her.
π¦ SYNOPSIS π¦
here's the whole flex, copy-paste ready, exactly as the ancestors wrote it:
# retrieve object instance
my $mime = Data::MIME->instance();
# return a hash reference of user defined types
my $types = $mime->custom_types;
# return the default mime-type for unknown files
$mime->default
# set the default mime-type with Dancer::Config or Dancer, like
set default_mime_type => "text/plain";
# or directly in your config.yml file.
# add non standard mime type
$mime->add_type( foo => "text/foo" );
# add an alias to an existing type
$mime->add_alias( bar => "foo" );
# get mime type for standard or non standard types
$nonstandard_type = $mime->for_name('foo');
$standard_type = $mime->for_name('svg');
# get mime type for a file (given the extension)
$mime_type = $mime->for_file("foo.bar");
bestie, note that the instance line up there literally says Data::MIME->instance() β that's what the page says, so that's what you get. don't come for me, I just work here. π
π PUBLIC API π
this is the part where we meet the whole squad. β¨
instance
my $mime = Dancer::MIME->instance();
hands you back the Dancer::MIME instance object. the one and only. main character energy, singleton behavior, iconic. π
add_type
# add nonstandard mime type
$mime->add_type( foo => "text/foo" );
adds a non standard mime type β or, plot twist, overrides one that already exists. sometimes you just gotta rewrite the rules. π₯
add_alias
# add alias to standard or previous alias
$mime->add_alias( my_jpg => 'jpg' );
adds an alias to an existing mime type. so now it answers to two names, like every good queen does. π
for_name
$mime->for_name( 'jpg' );
retrieves the mime type for a standard or non standard mime type. give her a name, she gives you the type. periodt. π
for_file
$mime->for_file( 'file.jpg' );
retrieves the mime type for a file β and it figures that out based on the file extension. π¦
custom_types
my $types = $mime->custom_types;
retrieves the full hash table of the mime types that have been added. all of them. the whole collection. π
name_or_type
my $type = $mime->name_or_type($thing);
resolves $thing into a content $type, whether $thing is the name of a MIME type like "txt" or is already a mime type like "text/plain". it just knows. iykyk. β
π AUTHORS π
ngl this module has been written and rewritten by a whole bunch of different people from the Dancer project. group project, but make it legendary. π«Ά
π LICENCE π
this module is released under the same terms as Perl itself. slay, legally speaking. π
π SEE ALSO π
Dancer
go look at Dancer, bestie, that's the family. π¦
π AUTHOR π
Dancer Core Developers. absolute icons. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2010 by Alexis Sukrieh.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free free free, as it should be. πΈ
and that's a wrap onDancer::MIME(3pm), bestie β perlv5.40.1, dated2026-05-05, straight from the User Contributed Perl Documentation. stan a singleton, protect the mime types, hydrate, and don't forget to read your man pages. bye babes πβ¨ππ¦
π¦ where this page comes from
- ubuntu stonking: libdancer-perl 1.3522-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms