// url: /basic/set/32?str=s&uint=64&float=3.14&byte=8 func (c *BasicController) Set(ctx *wk.HttpContext) (result wk.HttpResult, err error) { var id int if i, ok := ctx.RouteData.Int("id"); ok { id = i } else { return wk.Data(0), nil } var count int = 0 for i := 0; i < len(c.data); i++ { d := c.data[i] if d.Int != id { continue } if x := ctx.FormValue("str"); x != "" { d.Str = x } if x, ok := ctx.FormInt("uint"); ok { d.Uint = uint64(x) } if x, ok := ctx.FormFloat("float"); ok { d.Float = float32(x) } if x, ok := ctx.FormInt("byte"); ok { d.Byte = byte(x) } count++ } return wk.Data(count), nil }