diff --git a/context.go b/context.go index 0959b9f..a4a3cf2 100644 --- a/context.go +++ b/context.go @@ -120,7 +120,14 @@ func (c *Context) SetCookie(cookie *http.Cookie) { http.SetCookie(c.Writer, cookie) } +func (c *Context) AlreadyHaveResult() (done bool, entry string) { + return c.resultentry == "", c.resultentry +} + func (c *Context) RESULT(output interface{}) error { + if c.resultentry == "" { + c.resultentry = "RESULT" + } var t = reflect.TypeOf(output) defer func(o *interface{}) { b, err := json.Marshal(o) @@ -149,7 +156,6 @@ func (c *Context) RESULT(output interface{}) error { cost := time.Now().Sub(c.starttime).Milliseconds() noticeStr := fmt.Sprintf("cost: %dms, output: '%s'", cost, string(b)) log.NoticefWithDepth(calldepth, noticeStr) - }(&output) if _, ok := t.FieldByName("ErrCode"); !ok {