|
|
@ -9,33 +9,36 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Data struct {
|
|
|
|
type Data struct {
|
|
|
|
identifier string
|
|
|
|
Identifier string
|
|
|
|
password string
|
|
|
|
Password string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|
url := "http://localhost:8088" // Remplacez par l'URL de votre choix
|
|
|
|
url := "http://localhost:8088" // Remplacez par l'URL de votre choix
|
|
|
|
data := Data {
|
|
|
|
data := Data {
|
|
|
|
identifier: "machevaldo",
|
|
|
|
Identifier: "machevaldo",
|
|
|
|
password: "superPassword"}
|
|
|
|
Password: "superPassword"}
|
|
|
|
|
|
|
|
|
|
|
|
jsonData, err := json.Marshal(data)
|
|
|
|
jsonData, err := json.Marshal(data)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var m Data
|
|
|
|
|
|
|
|
err1 := json.Unmarshal(jsonData, &m)
|
|
|
|
|
|
|
|
if err1 != nil {
|
|
|
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(m)
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
|
|
|
|
client := &http.Client{}
|
|
|
|
client := &http.Client{}
|
|
|
|
resp, err := client.Do(req)
|
|
|
|
resp, err := client.Do(req)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("Response Status:", resp.Status)
|
|
|
|
fmt.Println("Response Status:", resp.Status)
|
|
|
|
}
|
|
|
|
}
|