You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
694 B
42 lines
694 B
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
type Data struct {
|
|
identifier string
|
|
password string
|
|
}
|
|
|
|
func main() {
|
|
url := "http://localhost:8088" // Remplacez par l'URL de votre choix
|
|
data := Data {
|
|
identifier: "machevaldo",
|
|
password: "superPassword"}
|
|
|
|
jsonData, err := json.Marshal(data)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
fmt.Println("Response Status:", resp.Status)
|
|
}
|