expressjs / response-time

Response time header for node.js
MIT License
472 stars 73 forks source link

Add a callback to the function signature. Add test Coverage. #7

Closed christophertrev closed 9 years ago

christophertrev commented 9 years ago

Added an optional callback argument for responseTime. This callback will take one argument, the response time of the request. All the old tests still pass. I added new tests to cover the new functionality.

Example Usage:

var express = require('express')
var responseTime = require('./response-time')

var app = express()

app.use(responseTime({digits: 5}, function(responseTime){
  console.log("Response time:", responseTime)
}))

app.get('/', function (req, res) {
  res.send('hello, world!')
})

app.listen(3000);

I added the callback as an argument, instead of a property in the options object, to keep in line with the pattern that node functions follow.

dougwilson commented 9 years ago

Thank you and sorry for the delay! A similar feature has been added to 2.3.0.