import { typeofrequest } from "https://deno.land/x/type_is@1.0.3/mod.ts";
Check if the incoming request's header contains the "Content-Type"
header field, and it contains any of the give mime type
s.
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.
Examples:
// With Content-Type: text/html; charset=utf-8
typeofrequest(header, [ 'html' ]); // => 'html'
typeofrequest(header, ['text/html' ]); // => 'text/html'
typeofrequest(header, ['text/*', 'application/json' ]); // => 'text/html'
// When Content-Type is application/json
typeofrequest(header, [ 'json', 'urlencoded' ]); // => 'json'
typeofrequest(header, [ 'application/json' ]); // => 'application/json'
typeofrequest(header, [ 'html', 'application/*' ]); // => 'application/json'
typeofrequest(header, [ 'html' ]); // => false
Parameters
header: Headers