From cc55c7b1b6b689e9c8fe622a0063083fca3595a7 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Mon, 30 Dec 2024 20:29:26 +0100 Subject: [PATCH] First Commit. --- README.md | 3 +++ go.mod | 3 +++ main.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 README.md create mode 100644 go.mod create mode 100644 main.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e97bdd --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Goffy + +Basic iffy.cert.hr front, for now just a cli tool. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2177089 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module crony/goffy + +go 1.23.4 diff --git a/main.go b/main.go new file mode 100644 index 0000000..4740e9b --- /dev/null +++ b/main.go @@ -0,0 +1,45 @@ +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) +}