// postData sends an http POST requests for every json file in files
postData sends an http POST requests for every json file in files
// postData sends an http POST requests for every json file in files
func postData(files []string, url string) {
	for _, f := range files {
		_, filename := filepath.Split(f)
		fmt.Printf("Sending %s to %s...", filename, "localhost")
		requestBody := bytes.NewBuffer(loadJSONFile(f))
		response, err := http.Post(url, "application/json", requestBody)
		if err != nil {
			fmt.Println("http post error")
			return
		}
		responseBody, err := ioutil.ReadAll(response.Body)
		if err != nil {
			fmt.Println("body read error")
			return
		}
		if string(responseBody) == "" {
			responseBody = []byte("No response body")
		}
		fmt.Printf("  %s: %s\n", response.Status, responseBody)
	}
}
func postData ( files [ ] string , url string ) { for _ , f := range files { _ , filename := filepath . Split ( f ) fmt . Printf ( " " , filename , " " ) requestBody := bytes . NewBuffer ( loadJSONFile ( f ) ) response , err := http . Post ( url , " " , requestBody ) if err != nil { fmt . Println ( " " ) return } responseBody , err := ioutil . ReadAll ( response . Body ) if err != nil { fmt . Println ( " " ) return } if string ( responseBody ) == " " { responseBody = [ ] byte ( " " ) } fmt . Printf ( " \n " , response . Status , responseBody ) } }
postData sends an http POST requests for every json file in files
postData sends an http POST requests for every json file in files