package

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

  1. Add the dependency to your shard.yml:

    dependencies:
      mime-types:
        github: benemohamed/mime-types
  2. 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

  1. Fork it (https://github.com/benemohamed/mime-types/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

License

GitHub license

API

  • Mime

    alias MimeTypes = Hash(String, MimeType)