mirror of
https://github.com/expressjs/expressjs.com.git
synced 2026-02-21 19:41:33 +00:00
23 lines
502 B
Plaintext
23 lines
502 B
Plaintext
section
|
|
h3(id='req.is') req.is(type)
|
|
|
|
p.
|
|
Check if the incoming request contains the "Content-Type"
|
|
header field, and it matches the give mime <code>type</code>.
|
|
|
|
+js.
|
|
// 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
|