lib/framework/middleware.js
function consumes(ctx) {
  if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;

  var mimes = ctx.operation.spec.consumes ||
    ctx.operation.resource.api.spec.consumes || [];
  var prefix = describe(ctx);

  if (!mimes.length) {
    debug(prefix + 'consumes middleware disabled (no consumes)');
    return;
  }

  return function(req, res, next) {
    if (req.sf.text && !is(req, mimes)) {
      debug(prefix + 'consumes mime not supported: "%s" not in "%s"',
            req.headers['content-type'], mimes);

      var err = new Error('Unsupported Content-Type (' +
                          req.headers['content-type'] + '), supports: ' +
                          mimes.join(', '));
      err.statusCode = 415;
      err.expose = true;

      return res.sf.reply(err);
    }

    next();
  };
}
function consumes(ctx) {
  if (['HEAD', 'GET'].indexOf(ctx.operation.spec.method) >= 0) return;

  var mimes = ctx.operation.spec.consumes ||
    ctx.operation.resource.api.spec.consumes || [];
  var prefix = describe(ctx);

  if (!mimes.length) {
    debug(prefix + 'consumes middleware disabled (no consumes)');
    return;
  }

  return function(req, res, next) {
    if (req.sf.text && !is(req, mimes)) {
      debug(prefix + 'consumes mime not supported: "%s" not in "%s"',
            req.headers['content-type'], mimes);

      var err = new Error('Unsupported Content-Type (' +
                          req.headers['content-type'] + '), supports: ' +
                          mimes.join(', '));
      err.statusCode = 415;
      err.expose = true;

      return res.sf.reply(err);
    }

    next();
  };
}
function consumes ( ctx ) { if ( [ 'HEAD' , 'GET' ] . indexOf ( ctx . operation . spec . method ) >= 0 ) return ; var mimes = ctx . operation . spec . consumes || ctx . operation . resource . api . spec . consumes || [ ] ; var prefix = describe ( ctx ) ; if ( ! mimes . length ) { debug ( prefix + 'consumes middleware disabled (no consumes)' ) ; return ; } return function ( req , res , next ) { if ( req . sf . text && ! is ( req , mimes ) ) { debug ( prefix + 'consumes mime not supported: "%s" not in "%s"' , req . headers [ 'content-type' ] , mimes ) ; var err = new Error ( 'Unsupported Content-Type (' + req . headers [ 'content-type' ] + '), supports: ' + mimes . join ( ', ' ) ) ; err . statusCode = 415 ; err . expose = true ; return res . sf . reply ( err ) ; } next ( ) ; } ; }
Check consumes.
Check consumes .