osm-spline / xappy.js

Xappy.JS
Other
37 stars 4 forks source link

wrap parser with the validator #93

Closed lusy closed 12 years ago

lusy commented 13 years ago

so that callbacks make sense. otherwise validator is called on the parsed request before it's known whether the parsing returns an error or no

mren commented 13 years ago

can you show us which lines of code do you mean?

lusy commented 13 years ago

do you think that this solution solves the problem? (these are lines 96-106 of the xappy.js) -> if the parser returns an error, we return with the callback, otherwise we send the parsedRequest through the validator as well

parse(pathname, function (err, xappyReq) { var content = req.headers['content-type']; if (err) { callback(res, content, err, xappyReq); } else { validate(xappyReq, function(err, xappyReq){ callback(res, content, err, xappyReq); }); } });

slomo commented 12 years ago

done since rewrite of xappy.js