You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current situation: Most camp layers (which I like to call "middlewares") call getQueries() at some point to, when it makes sense, retrieve and parse additional information about a request (e.g. POST data). This call may happen multiple times as a request moves through several layers (although a single call would be enough to populate request.query with all the data).
Problem: This causes "external middlewares" (new layers added with camp.handle()) to be called with an incomplete request.query (e.g. when a handler expects data sent via POST request, the data won't be available in the request.query it receives, because internally getQueries() will be called after the handler if at all).
Workaround: "external middlewares" don't have access to getQueries(), so they may re-implement its behavior by means of request.on("data") and request.on("end") listeners.
Suggested improvement: I think that getQueries() should actually be called only once, before any other layers (including camp.handle() layer), so that all layers have equal access to parsed POST data. Or getQueries could be called asynchronously, and handlers should have a wait to wait for its results to be available in order to process it.
The text was updated successfully, but these errors were encountered:
Current situation: Most
camp
layers (which I like to call "middlewares") callgetQueries()
at some point to, when it makes sense, retrieve and parse additional information about a request (e.g. POST data). This call may happen multiple times as a request moves through several layers (although a single call would be enough to populaterequest.query
with all the data).Problem: This causes "external middlewares" (new layers added with
camp.handle()
) to be called with an incompleterequest.query
(e.g. when a handler expects data sent via POST request, the data won't be available in therequest.query
it receives, because internallygetQueries()
will be called after the handler if at all).Workaround: "external middlewares" don't have access to
getQueries()
, so they may re-implement its behavior by means ofrequest.on("data")
andrequest.on("end")
listeners.Suggested improvement: I think that
getQueries()
should actually be called only once, before any other layers (includingcamp.handle()
layer), so that all layers have equal access to parsed POST data. OrgetQueries
could be called asynchronously, and handlers should have a wait to wait for its results to be available in order to process it.The text was updated successfully, but these errors were encountered: