Ai
1 Star 0 Fork 0

名字长点才好记/kratos

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
context.go 575 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tony Chen 提交于 2021-06-13 01:07 +08:00 . cmd: update cmd version (#1040)
package kratos
import (
"context"
)
// AppInfo is application context value.
type AppInfo struct {
ID string
Name string
Version string
Metadata map[string]string
Endpoints []string
}
type appKey struct{}
// NewContext returns a new Context that carries value.
func NewContext(ctx context.Context, s AppInfo) context.Context {
return context.WithValue(ctx, appKey{}, s)
}
// FromContext returns the Transport value stored in ctx, if any.
func FromContext(ctx context.Context) (s AppInfo, ok bool) {
s, ok = ctx.Value(appKey{}).(AppInfo)
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kaopuke/kratos.git
git@gitee.com:kaopuke/kratos.git
kaopuke
kratos
kratos
main

搜索帮助