I make a post request handler as follows (MainController is beegae.Controller) :
func (this *MainController) Post() {
var object models.Object
// debug(this, string(this.Ctx.Input.CopyBody()))
err := json.Unmarshal(this.Ctx.Input.RequestBody, &object)
if err != nil {
debug(this, "Error "+err.Error())
this.Data["json"] = err
return
}
t, err := object.Save(this.AppEngineCtx)
if err != nil {
debug(this, err.Error())
this.Data["json"] = err
} else {
this.Data["json"] = &t
}
}
Without the line // debug(this, string(this.Ctx.Input.CopyBody())), I got the "Error unexpected end of JSON input".
When I look into the implementation of beegae/context/input.go, I found RequestBody field is only set in CopyBody() method (https://github.com/astaxie/beego/blob/master/context/input.go#L270). Is this intentional that RequestBody is only set by calling CopyBody()?
I make a post request handler as follows (MainController is beegae.Controller) : func (this *MainController) Post() { var object models.Object // debug(this, string(this.Ctx.Input.CopyBody())) err := json.Unmarshal(this.Ctx.Input.RequestBody, &object) if err != nil { debug(this, "Error "+err.Error()) this.Data["json"] = err return } t, err := object.Save(this.AppEngineCtx) if err != nil { debug(this, err.Error()) this.Data["json"] = err } else { this.Data["json"] = &t } }
Without the line // debug(this, string(this.Ctx.Input.CopyBody())), I got the "Error unexpected end of JSON input".
When I look into the implementation of beegae/context/input.go, I found RequestBody field is only set in CopyBody() method (https://github.com/astaxie/beego/blob/master/context/input.go#L270). Is this intentional that RequestBody is only set by calling CopyBody()?