MCPcopy
hub / github.com/fastify/fastify / onBadUrl

Function onBadUrl

fastify.js:638–664  ·  view source on GitHub ↗
(path, req, res)

Source from the content-addressed store, hash-verified

636 }
637
638 function onBadUrl (path, req, res) {
639 if (options.frameworkErrors) {
640 const id = getGenReqId(routeEventContext.server, req)
641 const childLogger = createChildLogger(routeEventContext, options.logger, req, id)
642
643 const request = new Request(id, null, req, null, childLogger, routeEventContext)
644 const reply = new Reply(res, request, childLogger)
645
646 const resolvedDisableRequestLogging = typeof disableRequestLogging === 'function' ? disableRequestLogging(req) : disableRequestLogging
647 if (resolvedDisableRequestLogging === false) {
648 childLogger.info({ req: request }, 'incoming request')
649 }
650
651 return options.frameworkErrors(new FST_ERR_BAD_URL(path), request, reply)
652 }
653 const body = JSON.stringify({
654 error: 'Bad Request',
655 code: 'FST_ERR_BAD_URL',
656 message: `'${path}' is not a valid url component`,
657 statusCode: 400
658 })
659 res.writeHead(400, {
660 'Content-Type': 'application/json',
661 'Content-Length': Buffer.byteLength(body)
662 })
663 res.end(body)
664 }
665
666 function onMaxParamLength (path, req, res) {
667 if (options.frameworkErrors) {

Callers

nothing calls this directly

Calls 3

getGenReqIdFunction · 0.85
createChildLoggerFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…