|
@@ -33,17 +33,16 @@ func (this *BaseController) Options() { |
|
@@ -33,17 +33,16 @@ func (this *BaseController) Options() { |
33
|
func (this *BaseController) AllowCross() {
|
33
|
func (this *BaseController) AllowCross() {
|
34
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
34
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
35
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
35
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
36
|
- //this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "uid, token,jwt, deviceid, appid,Content-Type,Authorization,from")
|
|
|
37
|
- this.Ctx.WriteString("")
|
36
|
+ this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
|
|
|
37
|
+ //this.Ctx.WriteString("")
|
38
|
}
|
38
|
}
|
39
|
|
39
|
|
40
|
func (this *BaseController) Prepare() {
|
40
|
func (this *BaseController) Prepare() {
|
41
|
-
|
|
|
42
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
41
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
|
|
42
|
+ this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
|
43
|
if this.Ctx.Input.Method() == "OPTIONS" {
|
43
|
if this.Ctx.Input.Method() == "OPTIONS" {
|
44
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
44
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
45
|
- //this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "uid, token,jwt, deviceid, appid,Content-Type,Authorization,from")
|
|
|
46
|
- this.Ctx.WriteString("")
|
45
|
+ //this.Ctx.WriteString("")
|
47
|
return
|
46
|
return
|
48
|
}
|
47
|
}
|
49
|
|
48
|
|
|
@@ -118,34 +117,3 @@ func (this *BaseController) Finish() { |
|
@@ -118,34 +117,3 @@ func (this *BaseController) Finish() { |
118
|
log.Info(fmt.Sprintf("<====Send to uid(%d) client: %d byte\nRequestId:%s RspBodyData: %s", this.RequestHead.Uid, length,this.RequestHead.GetRequestId(), string(strByte)))
|
117
|
log.Info(fmt.Sprintf("<====Send to uid(%d) client: %d byte\nRequestId:%s RspBodyData: %s", this.RequestHead.Uid, length,this.RequestHead.GetRequestId(), string(strByte)))
|
119
|
}
|
118
|
}
|
120
|
} |
119
|
} |
121
|
-
|
|
|
122
|
-// BaseControllerCallBack
|
|
|
123
|
-type BaseControllerCallBack struct {
|
|
|
124
|
- beego.Controller
|
|
|
125
|
- Query map[string]string
|
|
|
126
|
- JSONBody map[string]interface{}
|
|
|
127
|
- ByteBody []byte
|
|
|
128
|
-}
|
|
|
129
|
-
|
|
|
130
|
-func (this *BaseControllerCallBack) Prepare() {
|
|
|
131
|
- this.Query = map[string]string{}
|
|
|
132
|
- input := this.Input()
|
|
|
133
|
- for k := range input {
|
|
|
134
|
- this.Query[k] = input.Get(k)
|
|
|
135
|
- }
|
|
|
136
|
-
|
|
|
137
|
- if this.Ctx.Input.RequestBody != nil {
|
|
|
138
|
- log.Info("RecvHead:", string(this.Ctx.Input.Header("Authorization")))
|
|
|
139
|
- this.ByteBody = this.Ctx.Input.RequestBody
|
|
|
140
|
- }
|
|
|
141
|
-}
|
|
|
142
|
-
|
|
|
143
|
-func (this *BaseControllerCallBack) Resp(msg *Message) {
|
|
|
144
|
- this.Data["json"] = msg
|
|
|
145
|
- this.ServeJSON()
|
|
|
146
|
-}
|
|
|
147
|
-
|
|
|
148
|
-func (this *BaseControllerCallBack) Finish() {
|
|
|
149
|
- strByte, _ := json.Marshal(this.Data["json"])
|
|
|
150
|
- log.Debug("<====Send to client:\n", string(strByte))
|
|
|
151
|
-} |
|
|