Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate ECHO_HEADERS check? #151

Open
SgtPooki opened this issue Apr 11, 2024 · 0 comments
Open

fix: remove duplicate ECHO_HEADERS check? #151

SgtPooki opened this issue Apr 11, 2024 · 0 comments

Comments

@SgtPooki
Copy link
Member

if ([ECHO_HEADERS].includes(true)) {
app.addHook('onRequest', async (request, reply) => {
if (ECHO_HEADERS) {
log('fastify hook onRequest: echoing headers:')
Object.keys(request.headers).forEach((headerName) => {
log('\t %s: %s', headerName, request.headers[headerName])
})
}
})
app.addHook('onSend', async (request, reply, payload) => {
if (ECHO_HEADERS) {
log('fastify hook onSend: echoing headers:')
const responseHeaders = reply.getHeaders()
Object.keys(responseHeaders).forEach((headerName) => {
log('\t %s: %s', headerName, responseHeaders[headerName])
})
}
return payload
})

@SgtPooki SgtPooki changed the title fix: only add onSend and onReceive hooks if ECHO_HEADERS is set fix: remove duplicate ECHO_HEADERS check? Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant