framework-one / fw1

FW/1 - Framework One - is a lightweight, convention over configuration, MVC application framework for ColdFusion / CFML.
http://framework-one.github.io
Other
374 stars 141 forks source link

Make Full Request Body available #537

Open mjclemente opened 3 years ago

mjclemente commented 3 years ago

This is an enhancement request. Happy to help with a PR if it's deemed worthwhile.

I posted this on the Slack channel:

Did a little digging, and it looks like FW/1 doesn't have a built-in method or variable for accessing the request body (getHttpRequestData().content). Our app is receiving webhooks, and we want to access/store the entire payload. Since the framework is already parsing the body, maybe it makes sense to make this easily available to the app.

sneiland commented 3 years ago

Add a new configuration boolean variable variables.framework.decodeRerquestBodyMergeRC (defaulted to true to preserve existing behavior)

Update var bodyStruct = read_json( body ); if ( isStruct( bodyStruct ) ) { structAppend( request.context, bodyStruct ); } else { request.context[ 'body' ] = bodyStruct; }

to

var bodyStruct = read_json( body ); if ( isStruct( bodyStruct ) && decodeRerquestBodyMergeRC ) { structAppend( request.context, bodyStruct ); } else { request.context[ 'body' ] = bodyStruct; }

sneiland commented 3 years ago

Alternatively suggested "o piggy back on what sneiland said, perhaps a framework var along the lines of decodeRequestBodyTo with a default of "rc" which means key/value, or anything other than rc specifies the variable to write it into in rc. decodeRequestBodyTo = "requestbody" would yield rc.requestbody with the contents"