func InsertApData(w http.ResponseWriter, r *http.Request) {
decoder := json.NewDecoder(r.Body)
fmt.Printf("Request Body : ", decoder)
var apdata models.ApData
err := decoder.Decode(&apdata)
check(b.E(err))
_, err2 := stmt.InsertApData.Exec(apdata.Mac, apdata.RssiMax, apdata.RssiMin, apdata.LocDefId)
check(b.E(err2))
}
and data type for db
type ApData struct {
ID int `db:"id"`
Mac string `db:"mac"`
RssiMax uint64 `db:"rssi_max"`
RssiMin uint16 `db:"rssi_min"`
LocDefId uint64 `db:"loc_def_id"`
}
Why returning
Request Body : %!(EXTRA *json.Decoder=&{0xc820012b00 [] {[] 0 { false [] false 0 0} { false [] false 0 0} false} 0 { false [] false 0 0} 0 []})
also json :
{
"mac":"01:0a:95:9d:68:20",
"rssi_max":-73.50,
"rssi_min":-50.02,
"loc_def_id":1
}