urlapi = https://yandex.ru/safety/check
site for check = likegodak.club
content type =json
Pls help, I can’t read response in structure YndexResponseModel
am i doing right?
now response always nil
func main() {
result := CheckYandex("likegodak.club")
if result != nil {
fmt.Println(result.Info, result.Url)
}
}
func CheckYandex(site string) (status *YndexResponseModel) {
type (
Threatstr struct {
Threat string
}
YndexResponseModel struct {
Info []Threatstr
Url string
}
)
var (
apiurl string = "https://yandex.ru/safety/check"
cl = &http.Client{Timeout: 15 * time.Second}
strformat = fmt.Sprintf(`{"url": "%s"}`, site)
jsonStr = []byte(strformat)
)
r, err := http.NewRequest("POST", apiurl, bytes.NewBuffer(jsonStr))
r.Header.Set("content-type", "application/json")
r.Close = true
resp, err := cl.Do(r)
checkerror(err)
defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(status)
return status
}