-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to reset the buffer before sending. #1551
base: master
Are you sure you want to change the base?
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Thanks for the motivation and context! As an alternative, what do you think about adding a separate function call, like this:
I think this would allow you to have syntax like:
Or:
I'm not necessarily pushing for this, just exploring. From an API perspective, I guess it's largely a question fo whether these are separate actions. i.e. is there ever any use-case to "reset" without having to send? Or are the two functions really coupled? If the latter, then the parameter approach that you have makes sense. But I'm not sure the "reset" name fully/effectively conveys the intent of the flag. An alternative name might be "overwrite". Or perhaps even an inverted flag called "append" (defaulting to false). (i.e. noting that the "default" behavior is to append to the body, but that you can make calls to explicitly overwrite it). |
It looks like a good idea indeed. |
@mbarnach Oops, you're too fast... I had more thoughts. (see edit) :-) |
@dannys42 I'm working with the following ideas:
It seems to be quite a lot, but that would make sense in the case of error reporting. What are your thoughts on that approach? |
Allow to reset the buffer before sending the response.
Description
When sending a response using
.send
, the body content is inaccessible.But sometimes, it makes sense to reset the buffer before sending,
eg. an error handler that remove internal details,
sending a JSON payload, not kowing if there is already something inside, etc.
Motivation and Context
When capturing internal error and making them more explicit, eg. RFC 7807,
we need to reset the buffer to avoid appending internal content
or sending an invalid (JSON) payload.
How Has This Been Tested?
Add tests to check the resetted content for
String
,String?
andData
which is used by all underlying methods.
Checklist: