2018-08-12 10:50:03 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-29 21:01:19 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
|
"github.com/gogf/gf/net/ghttp"
|
2018-08-12 10:50:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-01-01 14:18:00 +08:00
|
|
|
type User struct {
|
|
|
|
Uid int `json:"uid"`
|
|
|
|
Name string `json:"name" p:"username"`
|
|
|
|
Pass1 string `json:"pass1" p:"password1"`
|
|
|
|
Pass2 string `json:"pass2" p:"password2"`
|
|
|
|
}
|
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
s := g.Server()
|
|
|
|
s.BindHandler("/user", func(r *ghttp.Request) {
|
2020-01-01 14:18:00 +08:00
|
|
|
var user *User
|
|
|
|
if err := r.Parse(&user); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-04-03 00:03:46 +08:00
|
|
|
r.Response.WriteJson(user)
|
|
|
|
})
|
|
|
|
s.SetPort(8199)
|
|
|
|
s.Run()
|
2018-08-12 10:50:03 +08:00
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
// http://127.0.0.1:8199/user?uid=1&name=john&password1=123&userpass2=123
|
|
|
|
// {"name":"john","pass1":"123","pass2":"123","uid":1}
|
|
|
|
}
|