Best practices for POST and related tests #108
Comments
|
Okay awesome, thank you. Re: item 1... Yes to HTTPController, and originally I had included the decode call as per the code comment and in the absence of other examples I could find:
But I see now that it is already called inside of your HTTPController code, cool - simplifies things nicely. On item 2, command line does what I need, thank you. I had seen this issue in browser-based projects before but not backend projects to this point, probably should have played around a bit more before flagging it - thanks for bearing with me. And the flag on RequestController is super helpful - just tried it, works well. All done here :) Thanks again. |
Btw, another reason HTTPController decodes the body for you (if and only if it plans to process the request) is because x-www-form-urlencoded data gets treated as query values for @HTTPQuery parameters, and so the body needs to be parsed prior to executing the responder method. I also realized you just brought up an important point: we really need a forum for Aqueduct. We'll get working on that. Closing this issue. |
Greetings:
A bit of a 2 part issue / question around the same topic...
1 - I may have missed documentation examples somewhere about this, but what I put together seems to be working. For a POST endpoint I'm just doing this inside my Controller class to get at the data I'm receiving:
First question is, all good here?
2 - The main reason I'm asking is because I get major failure when I run this through a test case, unless I comment out the first line completely (decodeBody()). Here's the error:
The code comments in request.dart indicate the need to call decodeBody() first and it does work just fine on a deployed server, but the test fail is a bit of a nuisance requiring manual edits before running the test. Is this a bug or am I doing something wrong?
Also, I can't get any custom logging to work at all in my controller classes when running through a test case - everything from trying to log to a remote system like Rollbar through to just a standard print statement. That also works fine when deployed but just not when running a test. Any recommendations on how to approach that? The issue above was pretty tough to diagnose without having any logging capabilities in my Controller code during a test run.
Thanks in advance!
The text was updated successfully, but these errors were encountered: