func (c *TestRESTfulRouterController) Post(context *lv.HttpContext) interface{} {
	params, err := context.PackStructForm((*RESTfulParam)(nil))
	if nil != err {
		return err.Error()
	}

	paramstruct := params.(*RESTfulParam)
	return lv.BodyJson(paramstruct)
}
//	输出json Content-Type = application/json
func (r *ReturnParamController) Json(params struct {
	T int
}) interface{} {
	type TStruct struct {
		ID   string
		Name string
	}
	t := TStruct{"1", "slowfei"}
	t2 := TStruct{"2", "slowfei_2"}

	var j SFJson.Json

	if params.T == 1 {
		j = leafveingo.BodyJson([]TStruct{t, t2})
	} else {
		j = leafveingo.BodyJson(t)
	}

	return j
}
Example #3
0
//	url 后缀为json
func (arc *RouterController) ForumJson(params struct {
	Bid int
	Tid int
}) interface{} {
	return leafveingo.BodyJson(params)
}
func (rc *TestReflectController) PostParams(params struct {
	Name string
	Pwd  string
}) interface{} {
	return lv.BodyJson(params)
}