BindJsonBody default use json decode req.Body to struct
(i interface{}, ctx dotweb.Context)
| 137 | |
| 138 | //BindJsonBody default use json decode req.Body to struct |
| 139 | func (b *userBinder) BindJsonBody(i interface{}, ctx dotweb.Context) (err error) { |
| 140 | fmt.Println("UserBind.BindJsonBody") |
| 141 | if ctx.Request().PostBody() == nil { |
| 142 | err = errors.New("request body can't be empty") |
| 143 | return err |
| 144 | } |
| 145 | err = json.Unmarshal(ctx.Request().PostBody(), i) |
| 146 | return err |
| 147 | } |
| 148 | |
| 149 | func newUserBinder() *userBinder { |
| 150 | return &userBinder{} |