Przeglądaj źródła

general post json

master
Patrick Peng Sun 8 lat temu
rodzic
commit
bc71af3b59
1 zmienionych plików z 16 dodań i 0 usunięć
  1. +16
    -0
      upload.go

+ 16
- 0
upload.go Wyświetl plik

fmt.Println(string(strJSON)) fmt.Println(string(strJSON))
return strJSON, nil return strJSON, nil
} }

func postJSON(jsonB []byte, targetURL string) (resp string, err error) {
req, err := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonB))
if err != nil {
return
}
client := &http.Client{}
r, err := client.Do(req)
if err != nil {
return
}
defer r.Body.Close()
b, _ := ioutil.ReadAll(r.Body)
resp = string(b)
return
}

Ładowanie…
Anuluj
Zapisz