First Commit.
This commit is contained in:
commit
cc55c7b1b6
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Goffy
|
||||
|
||||
Basic iffy.cert.hr front, for now just a cli tool.
|
45
main.go
Normal file
45
main.go
Normal 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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user