request-data
getRequestData(maxSize[optional], raw[optional], callback)
Wraps any fn(request, response)
function, parses the requests body, and calls the wrapped function with data as the last parameter.
Normal usage:
"/myRoute": ;
With a named handler:
// Handler { // ...}
handleThing
will be passed the arguments of request
, response
, data
"/myRoute": ;
If you want to use it with a custom router that adds params after request
/response
, it will still work.
// beelin syntax "/myRoute/`things`": ;
By default request-data will kill a request if you try and send it more than 1e6
bytes.
This can be overriden per handler:
;
Or globally:
getRequestDatamaxRequestSize = 1e10;
If dataSize is greater than maxSize or data fails to parse during JSON.parse
, the parse error is passed to the handler instead of data
You can handle this case by checking if data is an error:
"/myRoute":;