This commit is contained in:
+12
-11
@@ -2,9 +2,9 @@ package hotime
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
@@ -12,13 +12,14 @@ type Context struct {
|
||||
tag int64
|
||||
Resp http.ResponseWriter
|
||||
Req *http.Request
|
||||
Application *Application
|
||||
Application *Application
|
||||
RouterString []string
|
||||
Config Map
|
||||
Db *HoTimeDB
|
||||
resp Map
|
||||
RespData Map
|
||||
CacheIns
|
||||
SessionIns
|
||||
HandlerStr string //复写请求url
|
||||
}
|
||||
|
||||
//唯一标志
|
||||
@@ -33,8 +34,8 @@ func (this *Context) GetTag() int64 {
|
||||
//唯一标志
|
||||
func (this *Context) Mtd(router [3]string) Map {
|
||||
this.Application.Router[router[0]][router[1]][router[2]](this)
|
||||
d := this.resp
|
||||
this.resp = nil
|
||||
d := this.RespData
|
||||
this.RespData = nil
|
||||
return d
|
||||
}
|
||||
|
||||
@@ -45,8 +46,8 @@ func (this *Context) Display(statu int, data interface{}) {
|
||||
if statu != 0 {
|
||||
temp := Map{}
|
||||
|
||||
tpe:=this.Config.GetMap("error").GetString(ObjToStr(statu))
|
||||
if tpe==""{
|
||||
tpe := this.Config.GetMap("error").GetString(ObjToStr(statu))
|
||||
if tpe == "" {
|
||||
this.LastErr.SetError(errors.New("找不到对应的错误码"))
|
||||
}
|
||||
|
||||
@@ -57,19 +58,19 @@ func (this *Context) Display(statu int, data interface{}) {
|
||||
resp["result"] = data
|
||||
}
|
||||
|
||||
this.resp = resp
|
||||
this.RespData = resp
|
||||
|
||||
//this.Data=d;
|
||||
}
|
||||
|
||||
func (this *Context) View() {
|
||||
if this.resp == nil {
|
||||
if this.RespData == nil {
|
||||
return
|
||||
}
|
||||
d, err := json.Marshal(this.resp)
|
||||
d, err := json.Marshal(this.RespData)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
this.resp = nil
|
||||
this.RespData = nil
|
||||
this.Resp.Write(d)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user