46 lines
846 B
Go
46 lines
846 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
type Result struct {
|
|
Exist bool `json:"exist"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
func main() {
|
|
// Url to send request to
|
|
iffy_url := "https://iffy.cert.hr/validate"
|
|
|
|
// Json to send
|
|
jsonData := []byte(`{"match": "ekupi.hr"}`)
|
|
|
|
// Creating a http request, and making a http request
|
|
request, err := http.NewRequest("POST", iffy_url, bytes.NewBuffer(jsonData))
|
|
request.Header.Set("Content-type", "application/json")
|
|
|
|
client := &http.Client{}
|
|
response, err := client.Do(request)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// Read the body request
|
|
defer response.Body.Close()
|
|
body, _ := io.ReadAll(response.Body)
|
|
|
|
var result Result
|
|
|
|
// Read the json parse it
|
|
if err := json.Unmarshal(body, &result); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println(result.Message)
|
|
}
|