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

x/opine/src/request.ts>WrappedRequest#is

Minimalist web framework for Deno ported from ExpressJS.
Latest
method WrappedRequest.prototype.is
import { WrappedRequest } from "https://deno.land/x/opine@2.3.4/src/request.ts";

Check if the incoming request contains the "Content-Type" header field, and it contains the give mime type.

Examples:

 // With Content-Type: text/html; charset=utf-8
 req.is('html');
 req.is('text/html');
 req.is('text/*');
 // => true

 // When Content-Type is application/json
 req.is('json');
 req.is('application/json');
 req.is('application/*');
 // => true

 req.is('html');
 // => false

Parameters

types: string | string[]