sigildocs

(sigil http mime)

(sigil http mime) - MIME Type Detection

Provides functions for detecting MIME types from file extensions.

Exports

*mime-types*variable

Default MIME type mappings Stored as mutable alist for runtime registration

Get MIME type for file extension.

The extension can be with or without a leading dot. Returns "application/octet-stream" if the type is unknown.

(mime-type-for-extension "html")   ; => "text/html"
(mime-type-for-extension ".json")  ; => "application/json"
(mime-type-for-extension "xyz")    ; => "application/octet-stream"

Get MIME type for a file path.

Extracts the extension from the path and looks up the type. Returns "application/octet-stream" if no extension or unknown type.

(mime-type-for-file "index.html")       ; => "text/html"
(mime-type-for-file "/img/photo.png")   ; => "image/png"

Register a custom MIME type mapping.

The extension can be with or without a leading dot.

(mime-type-register! "sgl" "text/x-sigil")
(mime-type-for-extension "sgl")  ; => "text/x-sigil"