# Copyright (C) 2008-2009, Sebastian Riedel. package MojoX::Types; use strict; use warnings; use base 'Mojo::Base'; __PACKAGE__->attr( types => ( chained => 1, default => sub { return { css => 'text/css', ico => 'image/x-icon', gif => 'image/gif', html => 'text/html', jpg => 'image/jpeg', js => 'application/x-javascript', phtml => 'text/html', png => 'image/png', txt => 'text/plain' }; } ) ); # Magic. Got it. sub type { my ($self, $ext, $type) = @_; # Set if ($type) { $self->types->{$ext} = $type; return $self; } return $self->types->{$ext || ''}; } 1; __END__ =head1 NAME MojoX::Types - Types =head1 SYNOPSIS use MojoX::Types; my $types = MojoX::Types->new; =head1 DESCRIPTION L is a container for MIME types. =head2 ATTRIBUTES =head2 C my $map = $types->types; $types = $types->types({png => 'image/png'}); =head1 METHODS L inherits all methods from L and implements the follwing the ones. =head2 C my $type = $types->type('png'); $types = $types->type(png => 'image/png'); =cut