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

[Feature Request] Add response body in middlewares before and after request #244

Closed
sansyrox opened this issue Jul 21, 2022 · 1 comment · Fixed by #250
Closed

[Feature Request] Add response body in middlewares before and after request #244

sansyrox opened this issue Jul 21, 2022 · 1 comment · Fixed by #250
Labels
good first issue Good for newcomers

Comments

@sansyrox
Copy link
Member

sansyrox commented Jul 21, 2022

Current Behavior

Now, there are four issues related to this topic:

  • It should be possible to access response["body"] in the after_request middleware.
  • There is no response dictionary accessible in the middleware. We only return the request object.
  • If we have a before_request middleware before a middleware then we can't access the body in the post route.
  • And finally, we can't even access the body in before_request

Try adding this in the base_routes:

@app.before_request("/post_with_body")
async def hello_before_request(request):
    global callCount
    callCount += 1
    print(request)
    return ""


@app.after_request("/post_with_body")
async def hello_after_request(request):
    global callCount
    callCount += 1
    print(request)
    return ""

Desired Behavior

Issues are fixed 😅


Screenshots / Mockups

Alternatives


@sansyrox sansyrox added the good first issue Good for newcomers label Jul 21, 2022
@sansyrox sansyrox reopened this Jul 28, 2022
@sansyrox sansyrox changed the title [Feature Request] Add body in middlewares before and after request [Feature Request] Add response body in middlewares before and after request Oct 7, 2022
@sansyrox
Copy link
Member Author

This is complete!

@sansyrox sansyrox mentioned this issue Oct 28, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
1 participant