Dancer2...re::MIME(3)

πŸ’– Dancer2::Core::MIME β€” the manual, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, and let me tell you about Dancer2::Core::MIME (that's the Dancer2...re::MIME(3) page, she's just got a long name and the terminal cut her off, it's giving ✨abbreviated✨). This is the class that makes MIME types not a whole nightmare. πŸ¦‹


🌸 NAME 🌸

Dancer2::Core::MIME β€” a class to ease manipulation of MIME types. literally that's her whole job and she's slaying it πŸ’…


⭐ VERSION ⭐

version 2.2.1 β€” periodt, that's the one we're on πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe, code and all, verbatim because I would never mess with your copy-paste:

use Dancer2::Core::MIME;

my $mime = Dancer2::Core::MIME->new();

# get mime type for an alias
my $type = $mime->for_name('css');

# set a new mime type
my $type = $mime->add_type( foo => 'text/foo' );

# set a mime type alias
my $alias = $mime->add_alias( f => 'foo' );

# get mime type for a file (based on extension)
my $file = $mime->for_file( "foo.bar" );

# set the $thing into a content $type.
my $type = $mime->name_or_type($thing);

# get current defined default mime type
my $type = $mime->default;

# set the default mime type using config.yml
# or using the set keyword
set default_mime_type => 'text/plain';

look at her go. main character energy fr fr πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

Dancer2::Core::MIME is a thin wrapper around MIME::Types, and what it does is hand you a bunch of helpful methods for MIME handling. that's it, that's the whole thing β€” no cap, she's the lowkey useful friend who just quietly handles it πŸ’œ


✨ ATTRIBUTES ✨

πŸ’– custom_types

Custom user-defined MIME types β€” the ones you add in with add_type. your own little collection, your own little slay 🌸

πŸ’– default

The default MIME type defined by MIME::Types, and it's set to: application/data. so if nobody says otherwise, that's the one showing up to the party πŸ™ˆ


🌈 METHODS 🌈

🌟 reset_default

Deprecated, bestie β€” use reset_to_default instead. I'm not mad I'm just disappointed, move on πŸ’€

🌟 reset_to_default

This method resets mime_type to the default type. fresh start, clean slate, rebrand πŸŽ€

🌟 add_type

This method adds the new MIME type. new type just dropped ✨

🌟 add_alias

The add_alias sets a MIME type alias. nickname acquired 🫢

🌟 for_name

The method for_name gets MIME type for an alias. you give the alias, it gives the type. transactional, iconic πŸ’…

🌟 for_file

This method gets MIME type for a file based on extension. yes based on the extension, she's not out here reading your file's soul, just the ending πŸ‘‘

🌟 name_or_type

This method sets the customized MIME name or default MIME type into a content type. so like, whatever you hand her becomes a content type. chef's kiss 😭


πŸ’œ AUTHOR πŸ’œ

Dancer Core Developers β€” the collective. the committee. the girlies 🧚


This software is copyright (c) 2026 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 software fr fr, go wild, just keep the same terms as Perl 5 itself 🫢

and that's the page bestie!! this beauty shipped as perl v5.42.3, dated 2026-09-20, and it lives in the User Contributed Perl Documentation corner of the world πŸ’– mwah, go set some MIME types, you're doing amazing βœ¨πŸŒˆπŸ’…

πŸ“¦ where this page comes from