-
Notifications
You must be signed in to change notification settings - Fork 179
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
[bug] http.Request.Body is not readable in RegisterInterceptFunc or RegisterBeforeFunc #80
Labels
Comments
Happy for a PR (with tests) to fix this.
|
Hi @elithrar! Please check the PR above. |
@elithrar up |
up |
AlexVulaj
pushed a commit
that referenced
this issue
Mar 6, 2024
…Func (#81) Hi! This PR gives users the ability to access and change `request.Body` in functions registered with `RegisterInterceptFunc` and `RegisterBeforeFunc`. I've already described it in issue #80. Also, I've added couple of simple tests to check ability to change request data in these functions. **Changes:** 1. In **rpc/v2** close `request.Body` after the execution of `beforeFunc`'s and `interceptFunc`'s. Update codec request info after calls to functions above. 2. Read request body bytes, decode it to codec format and provide `bytes.Buffer` and `request.Body` for underlying functions in **v2/json**, **v2/json2** and **v2/protorpc** codecs. Of course, exists a better way to do that, but it will require changes in the signature of `RegisterInterceptFunc` and `RegisterBeforeFunc` and it would be breaking changes. If both of these methods will have an original `*http.Request` as input parameter, they could be executed before the creation of codec. In this case, users can access and alter request data, and only after that it would be read by the codec and marshaled to service request params. But since these changes are breaking, it's not an option at the moment, probably it can fit the next version or release. Would be nice to know your opinion, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Versions
Steps to Reproduce
Expected behavior
I can make PR to change this behavior if these changes are ok. Also, it wouldn't be breaking changes.
Thanks for the package and looking forward to your feedback!
The text was updated successfully, but these errors were encountered: