Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/xserver/src/deps.ts>media.formatMediaType

X-Server a Deno server module with middleware
Go to Latest
function media.formatMediaType
Re-export
import { media } from "https://deno.land/x/xserver@5.0.0/src/deps.ts";
const { formatMediaType } = media;

Serializes the media type and the optional parameters as a media type conforming to RFC 2045 and RFC 2616.

The type and parameter names are written in lower-case.

When any of the arguments results in a standard violation then the return value will be an empty string ("").

Examples

Example 1

import { formatMediaType } from "https://deno.land/std@0.224.0/media_types/format_media_type.ts";

formatMediaType("text/plain", { charset: "UTF-8" }); // `text/plain; charset=UTF-8`

Parameters

type: string
optional
param: Record<string, string> | Iterable<[string, string]>

Returns

string