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

Function PostJsonBind

example/bind/main.go:83–97  ·  view source on GitHub ↗
(ctx dotweb.Context)

Source from the content-addressed store, hash-verified

81}
82
83func PostJsonBind(ctx dotweb.Context) error {
84 type UserInfo struct {
85 UserName string `json:"user"`
86 Sex int `json:"sex"`
87 }
88 user := new(UserInfo)
89 errstr := "no error"
90 if err := ctx.BindJsonBody(user); err != nil {
91 errstr = err.Error()
92 } else {
93
94 }
95
96 return ctx.WriteString("PostBind [" + errstr + "] " + fmt.Sprint(user))
97}
98
99func InitRoute(server *dotweb.HttpServer) {
100 server.Router().POST("/", TestBind)

Callers

nothing calls this directly

Calls 3

BindJsonBodyMethod · 0.65
ErrorMethod · 0.65
WriteStringMethod · 0.65

Tested by

no test coverage detected