req.is()

Returns true if this request’s declared “Content-Type” matches the specified media/mime type.

Specifically, this method matches the given type against this request’s “Content-Type” header.

Usage

  1. req.is(type);

Example

Assuming the request contains a “Content-Type” header, “text/html; charset=utf-8”:

  1. req.is('html');
  2. // -> true
  3. req.is('text/html');
  4. // -> true
  5. req.is('text/*');
  6. // -> true