MCPcopy
hub / github.com/fastify/fastify / onMaxParamLength

Function onMaxParamLength

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

Source from the content-addressed store, hash-verified

664 }
665
666 function onMaxParamLength (path, req, res) {
667 if (options.frameworkErrors) {
668 const id = getGenReqId(routeEventContext.server, req)
669 const childLogger = createChildLogger(routeEventContext, options.logger, req, id)
670
671 const request = new Request(id, null, req, null, childLogger, routeEventContext)
672 const reply = new Reply(res, request, childLogger)
673
674 const resolvedDisableRequestLogging = typeof disableRequestLogging === 'function' ? disableRequestLogging(req) : disableRequestLogging
675 if (resolvedDisableRequestLogging === false) {
676 childLogger.info({ req: request }, 'incoming request')
677 }
678
679 return options.frameworkErrors(new FST_ERR_MAX_PARAM_LENGTH(path), request, reply)
680 }
681 const body = JSON.stringify({
682 error: 'Bad Request',
683 code: 'FST_ERR_MAX_PARAM_LENGTH',
684 message: `'${path}' is exceeding the max param length`,
685 statusCode: 414
686 })
687 res.writeHead(414, {
688 'Content-Type': 'application/json',
689 'Content-Length': Buffer.byteLength(body)
690 })
691 res.end(body)
692 }
693
694 function buildAsyncConstraintCallback (isAsync, req, res) {
695 if (isAsync === false) return undefined

Callers

nothing calls this directly

Calls 3

getGenReqIdFunction · 0.85
createChildLoggerFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected