Updating this PR to limit it's scope to just JSON parsing.
I think the code included here to parse JSON bodies of response objects is good.
I think what's currently missing is error handling when JSON parsing of requests (which will then be passed on to handlers further in the chain) needs to be handled better.
As detailed in #205, when sending incorrect JSON, this handler will error and return a 500 Internal Server Error.
We should devise a way to make it so we can easily distinguish what kind of error to throw, and only return a 500 Internal Server Error as a last resort.
Updating this PR to limit it's scope to just JSON parsing.
I think the code included here to parse JSON bodies of response objects is good. I think what's currently missing is error handling when JSON parsing of requests (which will then be passed on to handlers further in the chain) needs to be handled better.
As detailed in #205, when sending incorrect JSON, this handler will error and return a 500 Internal Server Error.
We should devise a way to make it so we can easily distinguish what kind of error to throw, and only return a 500 Internal Server Error as a last resort.