index.js
function typeofrequest (req, types_) {
  var types = types_

  // no body
  if (!hasbody(req)) {
    return null
  }

  // support flattened arguments
  if (arguments.length > 2) {
    types = new Array(arguments.length - 1)
    for (var i = 0; i < types.length; i++) {
      types[i] = arguments[i + 1]
    }
  }

  // request content type
  var value = req.headers['content-type']

  return typeis(value, types)
}
function typeofrequest (req, types_) {
  var types = types_

  // no body
  if (!hasbody(req)) {
    return null
  }

  // support flattened arguments
  if (arguments.length > 2) {
    types = new Array(arguments.length - 1)
    for (var i = 0; i < types.length; i++) {
      types[i] = arguments[i + 1]
    }
  }

  // request content type
  var value = req.headers['content-type']

  return typeis(value, types)
}
function typeofrequest ( req , types_ ) { var types = types_ // no body if ( ! hasbody ( req ) ) { return null } // support flattened arguments if ( arguments . length > 2 ) { types = new Array ( arguments . length - 1 ) for ( var i = 0 ; i < types . length ; i ++ ) { types [ i ] = arguments [ i + 1 ] } } // request content type var value = req . headers [ 'content-type' ] return typeis ( value , types ) }
Check if the incoming request 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
this.is('html'); // => 'html'
this.is('text/html'); // => 'text/html'
this.is('text/*', 'application/json'); // => 'text/html'

// When Content-Type is application/json
this.is('json', 'urlencoded'); // => 'json'
this.is('application/json'); // => 'application/json'
this.is('html', 'application/*'); // => 'application/json'

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

@param {String|Array} types...
@return {String|false|null}
@public
Check if the incoming request 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 .