Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/doa/utils/typeIs.ts

A middleware framework for Deno's http serve🦕. Transplanted from Koa with ❤️
Latest
import * as doa from "https://deno.land/x/doa@v1.0.0/utils/typeIs.ts";

Variables

Normalize a mime type. If it's a shorthand, expand it to a valid mime type.

Functions

Check if a request's header has a request body. A request with a body must either have transfer-encoding or content-length headers set. http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3

Compare a value content-type with types. Each type can be an extension like html, a special shortcut like multipart or urlencoded, or a mime type.

Check if the incoming request's header contains the "Content-Type" header field, and it contains any of the give mime types. If there is no request body, null is returned. If there is no content type, false is returned. Otherwise, it returns the first type that matches.