| Class | Mack::Utils::MimeTypes |
| In: |
lib/mack/utils/mime_types.rb
|
| Parent: | Object |
Houses the MimeTypes used by the system to set the proper ‘Content-Type’ for requests.
Returns the type registered for the key, if there is no type for the key, then "text/html" is returned
Examples: Mack::Utils::MimeTypes.get(:iphone)
# => "app/iphone"
Mack::Utils::MimeTypes.get(:i_dont_exist)
# => "text/html"
# File lib/mack/utils/mime_types.rb, line 36
36: def get(name)
37: @types[name.to_sym] || "text/html"
38: end
Registers a new mime-type to the system. If the key already exists, it will be appended to the existing type.
Examples: Mack::Utils::MimeTypes.register(:iphone, "app/iphone")
"/users.iphone" # => will have a 'Content-Type' header of "app/iphone"
Mack::Utils::MimeTypes.register(:iphone, "application/mac-iphone")
"/users.iphone" # => will have a 'Content-Type' header of "app/iphone; application/mac-iphone"
# File lib/mack/utils/mime_types.rb, line 19
19: def register(name, type)
20: name = name.to_sym
21: if @types.has_key?(name)
22: @types[name] << "; " << type
23: else
24: @types[name] = type
25: end
26: end