This commit is contained in:
crusader 2017-11-27 19:58:54 +09:00
parent 0eefc4bd27
commit 596477790f

View File

@ -10,7 +10,7 @@ func (c ContextKey) String() string {
func NewContext(parent Context) Context {
c := &defaultContext{
parent: parent,
Context: parent,
}
c.attributes = make(map[string]interface{})
@ -25,7 +25,7 @@ type Context interface {
}
type defaultContext struct {
parent Context
Context
attributes map[string]interface{}
mtx sync.RWMutex
@ -50,10 +50,10 @@ func (dc *defaultContext) GetAttribute(key string) (value interface{}) {
return dc.attributes[key]
}
if nil == dc.parent {
if nil == dc.Context {
return nil
}
return dc.parent.GetAttribute(key)
return dc.Context.GetAttribute(key)
}
func (dc *defaultContext) RemoveAttribute(key string) {
@ -67,11 +67,11 @@ func (dc *defaultContext) RemoveAttribute(key string) {
return
}
if nil == dc.parent {
if nil == dc.Context {
return
}
dc.parent.RemoveAttribute(key)
dc.Context.RemoveAttribute(key)
}
func (dc *defaultContext) ContainsAttribute(key string) (exist bool) {
@ -84,10 +84,10 @@ func (dc *defaultContext) ContainsAttribute(key string) (exist bool) {
return true
}
if nil == dc.parent {
if nil == dc.Context {
return false
}
return dc.parent.ContainsAttribute(key)
return dc.Context.ContainsAttribute(key)
}
func (dc *defaultContext) checkInitialized() {