Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · mime

Docs

std/mime

On this page

Index

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.

Source: std/mime.xo:8

MimeErr

struct MimeErr {
  msg: Str
}

Go’s error texts: mime: no media type, mime: invalid media parameter, …

Source: std/mime.xo:14

MimeErr.display

fn (e: MimeErr) display() -> Str

Source: std/mime.xo:18

Functions

parse_media_type

fn parse_media_type(v: Str) -> MediaType ! MimeErr

text/html; charset=utf-8 into its parts (mime.ParseMediaType): RFC 2231 continuations and charsets (utf-8, us-ascii) decoded.

Source: std/mime.xo:22

format_media_type

fn format_media_type(kind: Str, params: Map[Str, Str]) -> Str

The 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.

Source: std/mime.xo:26

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.

Source: std/mime.xo:29

extensions_by_type

fn extensions_by_type(kind: Str) -> List[Str] ! MimeErr

The extensions of a media type, sorted (mime.ExtensionsByType).

Source: std/mime.xo:31

detect_content_type

fn detect_content_type(data: Bytes) -> Str

The media type of data from its first 512 bytes (WHATWG MIME Sniffing, net/http’s DetectContentType); “application/octet-stream” when nothing matches.

Source: std/mime.xo:35

↑ index