...
|
...
|
@@ -33,17 +33,16 @@ func (this *BaseController) Options() { |
|
|
func (this *BaseController) AllowCross() {
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
|
|
//this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "uid, token,jwt, deviceid, appid,Content-Type,Authorization,from")
|
|
|
this.Ctx.WriteString("")
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
|
|
|
//this.Ctx.WriteString("")
|
|
|
}
|
|
|
|
|
|
func (this *BaseController) Prepare() {
|
|
|
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
|
|
|
if this.Ctx.Input.Method() == "OPTIONS" {
|
|
|
this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
|
|
//this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "uid, token,jwt, deviceid, appid,Content-Type,Authorization,from")
|
|
|
this.Ctx.WriteString("")
|
|
|
//this.Ctx.WriteString("")
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -118,34 +117,3 @@ func (this *BaseController) Finish() { |
|
|
log.Info(fmt.Sprintf("<====Send to uid(%d) client: %d byte\nRequestId:%s RspBodyData: %s", this.RequestHead.Uid, length,this.RequestHead.GetRequestId(), string(strByte)))
|
|
|
}
|
|
|
} |
|
|
|
|
|
// BaseControllerCallBack
|
|
|
type BaseControllerCallBack struct {
|
|
|
beego.Controller
|
|
|
Query map[string]string
|
|
|
JSONBody map[string]interface{}
|
|
|
ByteBody []byte
|
|
|
}
|
|
|
|
|
|
func (this *BaseControllerCallBack) Prepare() {
|
|
|
this.Query = map[string]string{}
|
|
|
input := this.Input()
|
|
|
for k := range input {
|
|
|
this.Query[k] = input.Get(k)
|
|
|
}
|
|
|
|
|
|
if this.Ctx.Input.RequestBody != nil {
|
|
|
log.Info("RecvHead:", string(this.Ctx.Input.Header("Authorization")))
|
|
|
this.ByteBody = this.Ctx.Input.RequestBody
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (this *BaseControllerCallBack) Resp(msg *Message) {
|
|
|
this.Data["json"] = msg
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
func (this *BaseControllerCallBack) Finish() {
|
|
|
strByte, _ := json.Marshal(this.Data["json"])
|
|
|
log.Debug("<====Send to client:\n", string(strByte))
|
|
|
} |
...
|
...
|
|