media_type_of_path
Finds the media type of a file from the extension of its path or URL: images, fonts, web
documents, scripts and styles, data, audio and video. Case is ignored, and a query string or
fragment after the path is skipped. Pass it where a server or a blob needs a Content-Type.
Import
Section titled “Import”Cargo feature bytes (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path | &str | A file path or URL. |
Returns
Section titled “Returns”Option<&'static str> — The media type ("image/webp", …), or None for an unknown or missing extension.
