diff --git a/context.go b/context.go index b14c816..ca56c43 100644 --- a/context.go +++ b/context.go @@ -3,6 +3,7 @@ package hotime import ( "bytes" "encoding/json" + "errors" "io" "mime/multipart" "net/http" @@ -59,6 +60,9 @@ func (that *Context) Display(statu int, data interface{}) { resp["result"] = temp //兼容android等需要json转对象的服务 resp["error"] = temp + + that.Error.SetError(errors.New(resp.ToJsonString())) + } else { resp["result"] = data } diff --git a/example/main.go b/example/main.go index 9b7d943..3ccffe3 100644 --- a/example/main.go +++ b/example/main.go @@ -20,6 +20,9 @@ func main() { appIns.Run(Router{ "app": { "test": { + "test": func(that *Context) { + that.Display(2, "dsadasd") + }, // 测试入口 - 运行所有测试 "all": func(that *Context) { results := Map{}