mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-16 07:40:44 -07:00
refactor: use http.MethodPost
This commit is contained in:
parent
05f70b1a17
commit
16cee7c895
@ -99,7 +99,7 @@ func (t *Translator) Translate(message string) (translation *core.Translation, e
|
||||
"key": {initData.key},
|
||||
"token": {initData.token},
|
||||
}
|
||||
req, err := http.NewRequest("POST",
|
||||
req, err := http.NewRequest(http.MethodPost,
|
||||
fmt.Sprintf(textURL, initData.ig, initData.iid),
|
||||
strings.NewReader(userData.Encode()),
|
||||
)
|
||||
@ -128,7 +128,7 @@ func (t *Translator) Translate(message string) (translation *core.Translation, e
|
||||
// request part of speech
|
||||
userData.Del("fromLang")
|
||||
userData.Add("from", langCode[t.GetSrcLang()])
|
||||
req, err = http.NewRequest("POST",
|
||||
req, err = http.NewRequest(http.MethodPost,
|
||||
fmt.Sprintf(posURL, initData.ig, initData.iid),
|
||||
strings.NewReader(userData.Encode()),
|
||||
)
|
||||
@ -182,7 +182,7 @@ func (t *Translator) PlayTTS(lang, message string) error {
|
||||
"key": {initData.key},
|
||||
"token": {initData.token},
|
||||
}
|
||||
req, err := http.NewRequest("POST",
|
||||
req, err := http.NewRequest(http.MethodPost,
|
||||
fmt.Sprintf(ttsURL, initData.ig, initData.iid),
|
||||
strings.NewReader(userData.Encode()),
|
||||
)
|
||||
|
@ -56,7 +56,7 @@ func (t *Translator) Translate(message string) (translation *core.Translation, e
|
||||
}},
|
||||
"temperature": 0.7,
|
||||
})
|
||||
req, _ := http.NewRequest("POST",
|
||||
req, _ := http.NewRequest(http.MethodPost,
|
||||
textURL,
|
||||
bytes.NewBuffer(userData),
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ func (t *Translator) Translate(message string) (translation *core.Translation, e
|
||||
"languageDetection": "false",
|
||||
},
|
||||
})
|
||||
req, _ := http.NewRequest("POST",
|
||||
req, _ := http.NewRequest(http.MethodPost,
|
||||
textURL,
|
||||
bytes.NewBuffer(userData))
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
|
Loading…
x
Reference in New Issue
Block a user