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

net/http/blademaster 以 metadata 形式代替 Context.Keys 来传递上下文数据 #21

Closed
Terry-Mao opened this issue Apr 23, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@Terry-Mao
Copy link
Member

Terry-Mao commented Apr 23, 2019

Background

bm 中原来通过 Keys 字段在多个 handler 之间传递额外的数据,比如通过 token拿到的 userid。但是这种方式要求 http 层必须编写额外的代码来保证从 bm 的 Context 中获取了正确的 userid。

考虑到和 gRPC 的 metadata 模式与代码生成的一致性,考虑将 Keys 字段改成使用 valueContext 存储 metadata 来进行传递。

Suggestion

  1. 去除 bm 中 Context.Keys 改为使用类似 gRPC 中的 metadata 形式,metadata 存储与 valueContext 中,这样可以使 gRPC 的 service 逻辑与 bm 的 service 逻辑统一,也为之后网关全面迁移 gRPC 打下基础。

  2. metadata 的跨服务传递性?

Expected behaviour

bm Context 中的 Keys 字段被去除,并通过类似 gRPC 的 metadata 形式代替。

@Terry-Mao Terry-Mao added the enhancement New feature or request label Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants