Skip to content

Commit 25c96ce

Browse files
committed
add doc
1 parent a622d7f commit 25c96ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arcaptcha.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
)
99

10+
// arcaptchaApi arcaptcha verify API for captcha V2
1011
const arcaptchaApi = "https://arcaptcha.ir/2/siteverify"
1112

1213
type Website struct {
@@ -20,18 +21,25 @@ type verifyReq struct {
2021
ChallengeID string `json:"challenge_id"`
2122
}
2223

24+
// VerifyResp represents verify API response
25+
// error codes are available in https://docs.arcaptcha.ir/en/API/Verify
2326
type VerifyResp struct {
2427
Success bool `json:"success"`
2528
ErrorCodes []string `json:"error-codes"`
2629
}
2730

31+
// NewWebsite creates a new Website
2832
func NewWebsite(siteKey, secretKey string) *Website {
2933
return &Website{
3034
SiteKey: siteKey,
3135
SecretKey: secretKey,
3236
}
3337
}
3438

39+
// Verify calls arcaptcha verify API and returns result.
40+
//
41+
// if an error occurs while sending or receiving the request, returns error.
42+
// server side errors are available in VerifyResp.ErrorCodes.
3543
func (w *Website) Verify(token string) (VerifyResp, error) {
3644
data := &verifyReq{
3745
SiteKey: w.SiteKey,
@@ -43,6 +51,7 @@ func (w *Website) Verify(token string) (VerifyResp, error) {
4351
return resp, err
4452
}
4553

54+
// sendRequest sends http request to 'url' and fill 'resp' by response body
4655
func sendRequest(method, url string, data interface{}, resp interface{}) error {
4756
bin, err := json.Marshal(data)
4857
if err != nil {

0 commit comments

Comments
 (0)