This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
建议对外开放Context的定义 #42
Labels
Comments
先定义一个自定义的Ctx: type Ctx struct {
*tango.Context
User *User //自定义的字段
}
//SetContext is the implement for tango interface
func (c *Ctx) SetContext(ctx *tango.Context) {
c.Context = ctx
c.User = ... //设置User
} 然后使用这个Ctx替换 type Action struct {
Ctx
}
func (a *Action) Get() interface{} {
return a.User.Name
} |
对啊,有Contexter中间件和接口啊 |
...这个方法不错,可以暂时解决我的问题. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
想在Context里注入一些自定义的东西.但是目前无法实现.
是否考虑下Context采用interface的方式,默认返回内置的Context
The text was updated successfully, but these errors were encountered: