lib/framework/middleware.js
function produces(ctx) {
  var mimes = ctx.operation.spec.produces ||
    ctx.operation.resource.api.spec.produces || [];
  var prefix = describe(ctx);

  if (!mimes.length) {
    debug(prefix + 'produces validation disabled (no produces)');
  }

  return function(req, res, next) {
    req.sf.accept = accepts(req);

    if (!mimes.length) return next();

    var types = req.sf.accept.types(mimes);

    if (!types) {
      debug(prefix + 'produces mime not supported: "%s" not in "%s"',
            req.headers.accept, mimes);

      var err = new Error('Not acceptable (' +
                          req.headers.accept + '), supports: ' +
                          mimes.join(', '));
      err.statusCode = 406;
      err.expose = true;

      return res.sf.reply(err);
    }

    if (typeof types === 'string') types = [types];

    types.some(function(type) {
      if (!req.sf.router.encoder[type]) return;

      res.sf.produce = {
        encoder: req.sf.router.encoder[type],
        mime: type
      };

      return true;
    });

    next();
  };
}
function produces(ctx) {
  var mimes = ctx.operation.spec.produces ||
    ctx.operation.resource.api.spec.produces || [];
  var prefix = describe(ctx);

  if (!mimes.length) {
    debug(prefix + 'produces validation disabled (no produces)');
  }

  return function(req, res, next) {
    req.sf.accept = accepts(req);

    if (!mimes.length) return next();

    var types = req.sf.accept.types(mimes);

    if (!types) {
      debug(prefix + 'produces mime not supported: "%s" not in "%s"',
            req.headers.accept, mimes);

      var err = new Error('Not acceptable (' +
                          req.headers.accept + '), supports: ' +
                          mimes.join(', '));
      err.statusCode = 406;
      err.expose = true;

      return res.sf.reply(err);
    }

    if (typeof types === 'string') types = [types];

    types.some(function(type) {
      if (!req.sf.router.encoder[type]) return;

      res.sf.produce = {
        encoder: req.sf.router.encoder[type],
        mime: type
      };

      return true;
    });

    next();
  };
}
function produces ( ctx ) { var mimes = ctx . operation . spec . produces || ctx . operation . resource . api . spec . produces || [ ] ; var prefix = describe ( ctx ) ; if ( ! mimes . length ) { debug ( prefix + 'produces validation disabled (no produces)' ) ; } return function ( req , res , next ) { req . sf . accept = accepts ( req ) ; if ( ! mimes . length ) return next ( ) ; var types = req . sf . accept . types ( mimes ) ; if ( ! types ) { debug ( prefix + 'produces mime not supported: "%s" not in "%s"' , req . headers . accept , mimes ) ; var err = new Error ( 'Not acceptable (' + req . headers . accept + '), supports: ' + mimes . join ( ', ' ) ) ; err . statusCode = 406 ; err . expose = true ; return res . sf . reply ( err ) ; } if ( typeof types === 'string' ) types = [ types ] ; types . some ( function ( type ) { if ( ! req . sf . router . encoder [ type ] ) return ; res . sf . produce = { encoder : req . sf . router . encoder [ type ] , mime : type } ; return true ; } ) ; next ( ) ; } ; }
Check produces.
Check produces .