Skip to content

Conversation

@wu-clan
Copy link
Member

@wu-clan wu-clan commented Oct 14, 2025

close #827

@wu-clan wu-clan mentioned this pull request Oct 14, 2025
@wu-clan wu-clan requested a review from downdawn October 14, 2025 09:38
@downdawn
Copy link
Collaborator

使用starlette-context是不是会缺少IED提示,只能用get。
下面伪代码是否可以兼得

from starlette_context import context

class TypedContext:
    def __getattr__(self, key):
        return context.get(key)
    def __setattr__(self, key, value):
        context[key] = value

ctx = TypedContext()

ctx.user_id = "123"
print(ctx.user_id)

@wu-clan
Copy link
Member Author

wu-clan commented Oct 15, 2025

看起来很好,我会很快尝试一下

@wu-clan wu-clan merged commit 6a06579 into master Oct 16, 2025
5 checks passed
@wu-clan wu-clan deleted the update-request-state branch October 16, 2025 02:23
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.

全局上下文变量

3 participants