mimetypes
1 Overview
2 Function:   path->mimetype
path->mimetype
3 Mapping
4 Notes
9.1

mimetypes🔗ℹ

Hans Dijkema <hans@dijkewijk.nl>

 (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?
Returns the MIME type associated with p.

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:

  • .htmltext/html

  • .csstext/css

  • .jsapplication/javascript

  • .jsonapplication/json

  • .pngimage/png

  • .jpg, .jpegimage/jpeg

  • .svgimage/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.