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. πŸ‘‘


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 on Dancer::MIME(3pm), bestie β€” perl v5.40.1, dated 2026-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