express-latency-headers
Version:
Add latency headers to express
30 lines (21 loc) • 733 B
Markdown
This middleware adds two headers to the response.
- `x-request-received` is set by the server with the timestamp of when the request was received
- `x-response-sent` is set by the server with the timestamp of when the response was sent
[](https://github.com/montanaflynn/Latency-Headers-PoC) on why to add these headers.
```shell
npm install express-latency-headers --save
```
```javascript
var express = require('express')
var latencyHeaders = require('express-latency-headers')
var app = express()
app.use(latencyHeaders())
app.use(function(req, res, next) {
setTimeout(function(){
res.send('Hello World!')
},1000)
})
var server = app.listen(3000)
```