// parse header from request
const range = req.range(1000)
// the type of the range
if (range.type === 'bytes') {
// the ranges
range.forEach((r) => {
// do something with r.start and r.end
})
}
const express = require('express')
const app = express()
const router = express.Router()
// customizing the behavior of router.param()
router.param((param, option) => {
return (req, res, next, val) => {
if (val === option) {
next()
} else {
res.sendStatus(403)
}
})
// using the customized router.param()
router.param('id', 1337)
// route to trigger the capture
router.get('/user/:id', (req, res) => {
res.send('OK')
})
app.use(router)
app.listen(3000, () => {
console.log('Ready')
})
npm install express
// or
yarn add express