github.com/benemohamed/mime-types
0.1.0 / published Apr 16, 2020 / repository
mime-types The ultimate content-type utility.
mime-types
The ultimate content-type utility.
Installation
-
Add the dependency to your
shard.yml:dependencies: mime-types: github: benemohamed/mime-types -
Run
shards install
Usage
require "mime-types"
mime = Mime::Type.new
mime.lookup(path)
lookup = mime.lookup("file.json") # 'application/json'
mime.contentType(type)
contentType = mime.contentType("markdown") # 'text/markdown; charset=utf-8'
mime.extension(type)
extension = mime.extension("application/octet-stream") # 'bin'
type = mime::types
A map of content-types by extension.
extensions = mime::extensions
A map of extensions by content-type.
Development
crystal spec
Contributing
- Fork it (https://github.com/benemohamed/mime-types/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Mohamed Ben - creator and maintainer
License
API
- Mime
alias MimeTypes = Hash(String, MimeType)