GET請(qǐng)求
// get請(qǐng)求參數(shù)
s.BindHandler("GET:/test", func(r *ghttp.Request) {
username := r.GetString("username")
age := r.GetInt("age")
height := r.GetFloat64("height")
weight := r.GetFloat64("weight")
var info = struct{
UserName string `json:"username"`
Age int `json:"age"`
Height float64 `json:"height"`
Weight float64 `json:"weight"`
}{
username, age, height, weight,
}
r.Response.WriteJson(info)
})
POST請(qǐng)求
// post請(qǐng)求參數(shù)
s.BindHandler("POST:/test", func(r *ghttp.Request) {
username := r.GetPostString("username")
age := r.GetPostInt("age")
height := r.GetPostFloat64("height")
weight := r.GetPostFloat64("weight")
var info = struct{
UserName string `json:"username"`
Age int `json:"age"`
Height float64 `json:"height"`
Weight float64 `json:"weight"`
}{
username, age, height, weight,
}
r.Response.WriteJson(info)
})
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者