ark::mime

Variables

Defined in “ark/mime/mimedb.hh”:

  • constexpr auto *const MIMEDB_JSON
    This is a copy of the mime database at https://github.com/jshttp/mime-db/blob/master/db.json. It is just represented as a string here to allow us to compile it at runtime (and store in your binary).

    This is scraped from public data, but the actual content is MIT licensed.

Functions

Declared in “ark/mime/mimetype.hh”:

  • std::optional< std::string_view > content_type_for_path(const std::filesystem::path & path)
    Returns the content type for the given path. This resolves the extension against the mimedb and returns the content type, if any. Returns an empty optional if none are found.

  • std::optional< std::string_view > content_type_for_extension(const std::string & extension)
    Returns the content type for the given extension (with or without a leading dot). This resolves the extension against the mimedb and returns the content type, if any. Returns an empty optional if none are found.

  • std::optional< std::string_view > extension_for_content_type(const std::string & content_type)
    Returns an extension (with a leading dot) for the given content type. Returns an empty optional if that content type is unknown.

  • std::optional< std::string_view > content_type_for_url(const core::Url & url)
    Returns the content type for the given URL. This resolves the extension against the mimedb and returns the content type, if any. Returns an empty optional if none are found.