Skip to content
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 response body in middlewares before and after request #297

Conversation

Shending-Help
Copy link
Contributor

@Shending-Help Shending-Help commented Oct 27, 2022

Description
This PR fixes the issue with request body not being accessible in the middlewares and add a new feature of having the response object accessible in the before and after request middlwares

This PR fixes #244

@netlify
Copy link

netlify bot commented Oct 27, 2022

Deploy Preview for robyn canceled.

Name Link
🔨 Latest commit 66872d2
🔍 Latest deploy log https://app.netlify.com/sites/robyn/deploys/635a95e54871f600091d9cf8

@netlify
Copy link

netlify bot commented Oct 27, 2022

Deploy Preview for robyn canceled.

Name Link
🔨 Latest commit 5f0e3c7
🔍 Latest deploy log https://app.netlify.com/sites/robyn/deploys/637542db53b1f10008a182fe

@Shending-Help Shending-Help marked this pull request as draft November 2, 2022 13:29
@Shending-Help Shending-Help changed the title draft PR Add response body in middlewares before and after request Nov 2, 2022
@Shending-Help Shending-Help marked this pull request as ready for review November 2, 2022 13:48
Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @Shending-Help 😄

I have a few inline comments.

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shending-Help , can you please add one integration test to confirm the working of everything?

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some more inline comments on the PR. Thanks again 😄

@sansyrox
Copy link
Member

sansyrox commented Nov 7, 2022

@Shending-Help , there are some conflicts now. Apologies .

@Shending-Help
Copy link
Contributor Author

Shending-Help commented Nov 7, 2022

@sansyrox removed all dead code and addressed all comments and resolved the merge conflicts

@sansyrox
Copy link
Member

sansyrox commented Nov 7, 2022

Thanks @Shending-Help . Great work 😄

I will have a look tomorrow morning, Indian time.

@sansyrox
Copy link
Member

sansyrox commented Nov 7, 2022

@Shending-Help , can you please add one integration test too? I think you may have missed this comment. I'll still do a first review tomorrow morning 😄

@Shending-Help , can you please add one integration test to confirm the working of everything?

Comment on lines +109 to +118
response_dict.insert("headers", response_headers.into_py(py));
response_dict.insert("status", response_status_code.into_py(py));
response_dict.insert("body", response_body.into_py(py));

let output: PyResult<&PyAny> = match number_of_params {
0 => handler.call0(),
1 => handler.call1((request,)),
2 => handler.call1((request, response_dict)),
// this is done to accomodate any future params
2_u8..=u8::MAX => handler.call1((request,)),
3_u8..=u8::MAX => handler.call1((request, response_dict)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great. Just one last nit:

request and response_dict do not match. Can you rename them to request and response or req and res or request_dict and response_dict?

@sansyrox
Copy link
Member

sansyrox commented Apr 1, 2023

These have been implemented now. Hence, closing the PR

@sansyrox sansyrox closed this Apr 1, 2023
@sansyrox sansyrox deleted the 244-feature-response-body-middlware branch April 1, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add response body in middlewares before and after request
4 participants