std/mime
On this page
Index
- type
MediaType - type
MimeErr- method
MimeErr.display
- method
- fn
parse_media_type - fn
format_media_type - fn
type_by_extension - fn
extensions_by_type - fn
detect_content_type
Types
MediaType
struct MediaType {
kind: Str
params: Map[Str, Str]
}A media type: the type and subtype in lower case (“text/html”) and its parameters, names in lower case.
MimeErr
struct MimeErr {
msg: Str
}Go’s error texts: mime: no media type, mime: invalid media parameter, …
MimeErr.display
fn (e: MimeErr) display() -> StrFunctions
parse_media_type
fn parse_media_type(v: Str) -> MediaType ! MimeErrtext/html; charset=utf-8 into its parts (mime.ParseMediaType): RFC
2231 continuations and charsets (utf-8, us-ascii) decoded.
format_media_type
fn format_media_type(kind: Str, params: Map[Str, Str]) -> StrThe text of a media type and its parameters, sorted by name, quoted or RFC 2231 encoded as needed (mime.FormatMediaType); "" when the type or a name is not a token.
type_by_extension
fn type_by_extension(ext: Str) -> Str?The type of an extension (".png" -> “image/png”), from Go’s builtin table: an exact match, else without ASCII case.
extensions_by_type
fn extensions_by_type(kind: Str) -> List[Str] ! MimeErrThe extensions of a media type, sorted (mime.ExtensionsByType).
detect_content_type
fn detect_content_type(data: Bytes) -> StrThe media type of data from its first 512 bytes (WHATWG MIME Sniffing, net/http’s DetectContentType); “application/octet-stream” when nothing matches.
↑ index