simple-api
simple-api copied to clipboard
Simple API should parse POST requests
Right now, there's not support for POST request data parsing or any tests around POST requests.
I started to dig into this, but realized that it brought up some larger concerns (some of which were mentioned in #8. The largest one is synchronous v. asynchronous and how that affects the stack of Simple.
Really, what I think would be ideal here, is to adopt a sort of middle ware approach like Express that would allow easy insertion of the data parsing into the stack. Otherwise, we'll just have nested callbacks on nested callbacks all up in the handleHTTPRequest function...and that's no fun :-1:
Thoughts?
The handleHTTPRequest function really needs some cleanup. That if stack is getting fairly large there, and I've got a number of callbacks I intend to include soon. I will drop everything into closures when I do the next round of upgrades.
There are three potential solutions here. I like 1 and 2 equally, but think 3 is pretty lame:
- Add a new convenience function that parses the data and sends it back via a callback. The developer can then decide at runtime if they want Simple to take the time to process the request body.
- Add an option to the route configuration that specifies if the request body should be parsed. If that option is true the parsing happens behind the scenes and a new parameter is added to the controller action.
- Parse all request bodies. I suppose we could even define certain HTTP methods to automatically parse (PUT, POST). As I said, I don't like this one, because it potentially adds a good amount of overhead.
I definitely like 1 and 2 and not 3.
Did we make any progress on this? I'm happy to dive in and get it done, just wanted to check if you'd done anything (we need it for Cyoemus).
Haven't gotten there yet. Feel free to dive in, if you'd like. On Oct 9, 2013 6:27 PM, "Jesse Pollak" [email protected] wrote:
Did we make any progress on this? I'm happy to dive in and get it done, just wanted to check if you'd done anything (we need it for Cyoemus).
— Reply to this email directly or view it on GitHubhttps://github.com/josephwegner/simple-api/issues/9#issuecomment-26017957 .