// url: /basic/rangecount/?start=1&end=99 func (c *BasicController) RangeCount(ctx *wk.HttpContext) (result wk.HttpResult, err error) { start := ctx.FormIntOr("start", 0) end := ctx.FormIntOr("end", 0) var count int = 0 for _, d := range c.data { if d.Int >= start && d.Int <= end { count++ } } return wk.Data(count), nil }
// url: /basic/add/?int=32&str=string&uint=1024&float=1.1&byte=64 func (c *BasicController) Add(ctx *wk.HttpContext) (result wk.HttpResult, err error) { data := Data{ Int: ctx.FormIntOr("int", 0), Uint: uint64(ctx.FormIntOr("uint", 0)), Str: ctx.FormValue("str"), Float: float32(ctx.FormFloatOr("float", 0.0)), Byte: byte(ctx.FormIntOr("byte", 0)), } c.data = append(c.data, data) return wk.Data(data.String()), nil }