Skip to content

Commit

Permalink
docs(readme): fix genReqId() example (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabenGar committed Mar 3, 2023
1 parent 13415bc commit 652405f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ const logger = require('pino-http')({

// Define a custom request id function
genReqId: function (req, res) {
if (req.id) return req.id
let id = req.get('X-Request-Id')
if (id) return id
const existingID = req.id ?? req.headers["x-request-id"]
if (existingID) return existingID
id = randomUUID()
res.header('X-Request-Id', id)
res.setHeader('X-Request-Id', id)
return id
},

Expand Down

0 comments on commit 652405f

Please sign in to comment.