gin获取post的body里的参数
例子
在map2中即可获取 body中的参数
获取方式,参见postman

//sign in
authorized.POST("/signIn", func(context *gin.Context){
buf := make([]byte, 1024)
n, _ := context.Request.Body.Read(buf)
for i := 0; i < n; i +=1 {
if(buf[i] ==' ' || buf[i] == '\x00') {
buf = append(buf[:i], buf[(i + 1):]...)
n -= 1
}
}
map2 := make(map[string]string)
err = json.Unmarshal(buf[:n], &map2)
fmt.Println(map2)
t_nickName := map2["nickname"]
t_password := map2["password"]
})

浙公网安备 33010602011771号