-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ycvk/issue#8
Issue#8
- Loading branch information
Showing
6 changed files
with
90 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package pkg | ||
|
||
import ( | ||
"deeplx-local/domain" | ||
"github.com/imroc/req/v3" | ||
) | ||
|
||
const validResp = "我爱你" | ||
|
||
var validReq = domain.TranslateRequest{ | ||
Text: "I love you", | ||
SourceLang: "EN", | ||
TargetLang: "ZH", | ||
} | ||
|
||
// CheckURLAvailability 检查URL是否可用 | ||
func CheckURLAvailability(client *req.Client, url string) (bool, error) { | ||
var result domain.TranslateResponse | ||
response, err := client.R().SetBody(&validReq).SetSuccessResult(&result).Post(url) | ||
if err != nil { | ||
return false, err | ||
} | ||
defer response.Body.Close() | ||
return validResp == result.Data, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters