lib/v2/express-host.js
function hook(req, res, next) {
  var _end    = res.end;
  var _write  = res.write;
  //var _on     = res.on;

  res.write = function(chunk, encoding) {
    // ... other things

    // Call the original
    _write.call(this, chunk, encoding);

    // Note: in some cases, you have to restore the function:
    // res.write = _write;
  };

  res.end = function(chunk, encoding) {
    // ... other things

    // Call the original
    _end.call(this, chunk, encoding);

    // Note: in some cases, you have to restore the function:
    // res.end = _end;
  };

  return next();
}
function hook(req, res, next) {
  var _end    = res.end;
  var _write  = res.write;
  //var _on     = res.on;

  res.write = function(chunk, encoding) {
    // ... other things

    // Call the original
    _write.call(this, chunk, encoding);

    // Note: in some cases, you have to restore the function:
    // res.write = _write;
  };

  res.end = function(chunk, encoding) {
    // ... other things

    // Call the original
    _end.call(this, chunk, encoding);

    // Note: in some cases, you have to restore the function:
    // res.end = _end;
  };

  return next();
}
function hook ( req , res , next ) { var _end = res . end ; var _write = res . write ; //var _on     = res.on; res . write = function ( chunk , encoding ) { // ... other things // Call the original _write . call ( this , chunk , encoding ) ; // Note: in some cases, you have to restore the function: // res.write = _write; } ; res . end = function ( chunk , encoding ) { // ... other things // Call the original _end . call ( this , chunk , encoding ) ; // Note: in some cases, you have to restore the function: // res.end = _end; } ; return next ( ) ; }
Example of how to do Express.js middleware when you need to do something at the end
of the request.

@param {ServerRequest} req
@param {ServerResponse} res
@param {function} next
Example of how to do Express . js middleware when you need to do something at the end of the request .