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

  var limit = lookup(ctx.operation, 'options', 'bodyLimit') || '100kb';

  return function(req, res, next) {
    rawBody(req, {
      length: req.headers['content-length'],
      limit: limit,
      encoding: http.CHARSET
    }, function(err, text) {
      if (err) {
        if (err.statusCode) return res.sf.reply(err);
        return next(err);
      }

      req.sf.text = text;

      // Mimic body-parser for use by proxies
      if (text && text.length) {
        req.body = text;
      }

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

  var limit = lookup(ctx.operation, 'options', 'bodyLimit') || '100kb';

  return function(req, res, next) {
    rawBody(req, {
      length: req.headers['content-length'],
      limit: limit,
      encoding: http.CHARSET
    }, function(err, text) {
      if (err) {
        if (err.statusCode) return res.sf.reply(err);
        return next(err);
      }

      req.sf.text = text;

      // Mimic body-parser for use by proxies
      if (text && text.length) {
        req.body = text;
      }

      next();
    });
  };
}
function raw ( ctx ) { if ( [ 'HEAD' , 'GET' ] . indexOf ( ctx . operation . spec . method ) >= 0 ) return ; var limit = lookup ( ctx . operation , 'options' , 'bodyLimit' ) || '100kb' ; return function ( req , res , next ) { rawBody ( req , { length : req . headers [ 'content-length' ] , limit : limit , encoding : http . CHARSET } , function ( err , text ) { if ( err ) { if ( err . statusCode ) return res . sf . reply ( err ) ; return next ( err ) ; } req . sf . text = text ; // Mimic body-parser for use by proxies if ( text && text . length ) { req . body = text ; } next ( ) ; } ) ; } ; }
Parse raw body.
Parse raw body .