First Commit.

This commit is contained in:
CronyAkatsuki 2024-12-30 20:29:26 +01:00
commit cc55c7b1b6
3 changed files with 51 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Goffy
Basic iffy.cert.hr front, for now just a cli tool.

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module crony/goffy
go 1.23.4

45
main.go Normal file
View File

@ -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)
}