1
0
justguestbook/pkg/justcaptcha/justcaptcha.go

21 lines
454 B
Go
Raw Normal View History

package justcaptcha
import (
"net/http"
"net/url"
)
// CheckCaptcha performs a request to a justcaptcha service and returns wether
// CAPTCHA was solved or not. If there is a problem with connection to the
// service it will return an error.
func CheckCaptcha(id string, serviceURL string) (bool, error) {
path, _ := url.JoinPath(serviceURL, id)
r, err := http.Get(path)
if err != nil {
return false, err
}
return r.StatusCode == 202, nil
}