mimetypes
| (require mimetypes) |
MIME type utilities used by the webview library.
This module provides a mapping from file extensions to MIME types together with a function to determine the MIME type of a file path.
1 Overview
The module is used by the local HTTPS server to determine the correct Content-Type header when serving files.
MIME types are determined based on the file extension.
2 Function: path->mimetype
procedure
(path->mimetype p) → string?
p : path-string?
The file extension of p is extracted and used to look up the corresponding MIME type.
If the extension is not recognized, a default MIME type is returned.
3 Mapping
The module contains a predefined mapping from file extensions to MIME types.
Typical mappings include:
.html → text/html
.css → text/css
.js → application/javascript
.json → application/json
.png → image/png
.jpg, .jpeg → image/jpeg
.svg → image/svg+xml
The exact mapping is defined in the source code and can be extended if needed.
4 Notes
The returned MIME type is always a string suitable for use in HTTP response headers.
File extensions are interpreted case-insensitively.