MCPcopy Create free account
hub / github.com/devfeel/dotweb / BindJsonBody

Method BindJsonBody

example/bind/main.go:139–147  ·  view source on GitHub ↗

BindJsonBody default use json decode req.Body to struct

(i interface{}, ctx dotweb.Context)

Source from the content-addressed store, hash-verified

137
138//BindJsonBody default use json decode req.Body to struct
139func (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
149func newUserBinder() *userBinder {
150 return &userBinder{}

Callers

nothing calls this directly

Calls 2

PostBodyMethod · 0.80
RequestMethod · 0.65

Tested by

no test coverage detected