- refactor jxcontext

This commit is contained in:
gazebo
2019-03-25 14:28:12 +08:00
parent 4e2cd5b26c
commit 82cf7cdb22
2 changed files with 64 additions and 32 deletions

View File

@@ -19,12 +19,9 @@ type IAuther interface {
}
type Context struct {
token string
accessUUID string
userInfo IAuther //*auth.LoginInfo
w http.ResponseWriter
r *http.Request
mapData map[interface{}]interface{}
*auth2.Context
token string
userInfo IAuther //*auth.LoginInfo
}
const (
@@ -41,22 +38,16 @@ func init() {
func NewWithUserName(notUsed interface{}, userName string, w http.ResponseWriter, r *http.Request) (ctx *Context) {
ctx = &Context{
token: userName,
w: w,
r: r,
mapData: make(map[interface{}]interface{}),
accessUUID: utils.GetUUID(),
token: userName,
Context: auth2.NewContext(w, r),
}
return ctx
}
func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Request) (ctx *Context, errCode string, err error) {
ctx = &Context{
token: token,
w: w,
r: r,
mapData: make(map[interface{}]interface{}),
accessUUID: utils.GetUUID(),
token: token,
Context: auth2.NewContext(w, r),
}
globals.SugarLogger.Debugf("jxcontext New, token:%s", token)
if auth2.IsV2Token(token) {
@@ -118,10 +109,6 @@ func (ctx *Context) GetToken() string {
return ctx.token
}
func (ctx *Context) GetAccessUUID() string {
return ctx.accessUUID
}
func (ctx *Context) GetLoginInfo() IAuther {
return ctx.userInfo
}
@@ -134,15 +121,3 @@ func (ctx *Context) GetV2AuthInfo() (authInfo *auth2.AuthInfo, err error) {
}
return nil, auth2.ErrNeedV2Token
}
func (ctx *Context) GetResponseWriter() http.ResponseWriter {
return ctx.w
}
func (ctx *Context) GetRequest() *http.Request {
return ctx.r
}
func (ctx *Context) GetTrackInfo() string {
return ctx.accessUUID
}