Compare commits

..

No commits in common. "9d6b294a6143c7639bf5daf9d06b0f1cc5bcb594" and "3f099d187c9d32ba18f3d8697442085186ef97e4" have entirely different histories.

View File

@ -108,13 +108,7 @@ func Router(cfg *Config) *gin.Engine {
// Free API endpoint, No Pro Account required
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
req := PayloadFree{}
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
"message": "Invalid request payload",
})
return
}
c.BindJSON(&req)
sourceLang := req.SourceLang
targetLang := req.TargetLang
@ -133,10 +127,9 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
"message": "Translation failed: " + err.Error(),
})
return
}
@ -163,13 +156,7 @@ func Router(cfg *Config) *gin.Engine {
// Pro API endpoint, Pro Account required
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
req := PayloadFree{}
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
"message": "Invalid request payload",
})
return
}
c.BindJSON(&req)
sourceLang := req.SourceLang
targetLang := req.TargetLang
@ -208,10 +195,9 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
"message": "Translation failed: " + err.Error(),
})
return
}
@ -265,10 +251,9 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
"message": "Translation failed: " + err.Error(),
})
return
}