Skip to content

Request state and scope#557

Merged
lovelydinosaur merged 10 commits intomasterfrom
request-state-and-scope
Jun 19, 2019
Merged

Request state and scope#557
lovelydinosaur merged 10 commits intomasterfrom
request-state-and-scope

Conversation

@lovelydinosaur
Copy link

@lovelydinosaur lovelydinosaur commented Jun 19, 2019

Follow up to #552

Adds request.scope and request.state.
Middleware now passes scope in-place.

Closes #545
Closes #551
Closes #552

At a later point we'll also want to start moving towards deprecating the request-as-dict interface, in favor of request.scope.

class aMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
request.state.foo = expected_value1
print("a", dict(request))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to remove these print statements?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. Yes, I do. Thanks!

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.

request.state is not persisted between middlewares. mypy errors when accessing Request.state

2 participants