草庐IT

postJson

全部标签

go进行http,get或postJson请求

1,http封装get,postJson类packagehttpUtilimport( "bytes" logxx"go-gift-panel/src/log" "io" "io/ioutil" "net/http")funcPostJson(urlstring,jsonData[]byte)string{ logxx.Log.Info("请求的url=",url,"请求的JSONData:",string(jsonData))//输出JSON格式的数据 resp,err:=http.Post(url,"application/json",bytes.NewBuffer(jsonData))/