add AlreadyHaveResult function
This commit is contained in:
parent
ba9357e166
commit
69b0fb05aa
@ -120,7 +120,14 @@ func (c *Context) SetCookie(cookie *http.Cookie) {
|
|||||||
http.SetCookie(c.Writer, 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 {
|
func (c *Context) RESULT(output interface{}) error {
|
||||||
|
if c.resultentry == "" {
|
||||||
|
c.resultentry = "RESULT"
|
||||||
|
}
|
||||||
var t = reflect.TypeOf(output)
|
var t = reflect.TypeOf(output)
|
||||||
defer func(o *interface{}) {
|
defer func(o *interface{}) {
|
||||||
b, err := json.Marshal(o)
|
b, err := json.Marshal(o)
|
||||||
@ -149,7 +156,6 @@ func (c *Context) RESULT(output interface{}) error {
|
|||||||
cost := time.Now().Sub(c.starttime).Milliseconds()
|
cost := time.Now().Sub(c.starttime).Milliseconds()
|
||||||
noticeStr := fmt.Sprintf("cost: %dms, output: '%s'", cost, string(b))
|
noticeStr := fmt.Sprintf("cost: %dms, output: '%s'", cost, string(b))
|
||||||
log.NoticefWithDepth(calldepth, noticeStr)
|
log.NoticefWithDepth(calldepth, noticeStr)
|
||||||
|
|
||||||
}(&output)
|
}(&output)
|
||||||
|
|
||||||
if _, ok := t.FieldByName("ErrCode"); !ok {
|
if _, ok := t.FieldByName("ErrCode"); !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user