mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-06-11 15:28:50 +00:00
Compare commits
No commits in common. "9d6b294a6143c7639bf5daf9d06b0f1cc5bcb594" and "3f099d187c9d32ba18f3d8697442085186ef97e4" have entirely different histories.
9d6b294a61
...
3f099d187c
@ -108,13 +108,7 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
// Free API endpoint, No Pro Account required
|
// Free API endpoint, No Pro Account required
|
||||||
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
|
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||||
req := PayloadFree{}
|
req := PayloadFree{}
|
||||||
if err := c.BindJSON(&req); err != nil {
|
c.BindJSON(&req)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"code": http.StatusBadRequest,
|
|
||||||
"message": "Invalid request payload",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceLang := req.SourceLang
|
sourceLang := req.SourceLang
|
||||||
targetLang := req.TargetLang
|
targetLang := req.TargetLang
|
||||||
@ -133,10 +127,9 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
|
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Translation failed: %s", err)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"code": http.StatusInternalServerError,
|
"code": http.StatusInternalServerError,
|
||||||
"message": "Translation failed",
|
"message": "Translation failed: " + err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -163,13 +156,7 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
// Pro API endpoint, Pro Account required
|
// Pro API endpoint, Pro Account required
|
||||||
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
|
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||||
req := PayloadFree{}
|
req := PayloadFree{}
|
||||||
if err := c.BindJSON(&req); err != nil {
|
c.BindJSON(&req)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"code": http.StatusBadRequest,
|
|
||||||
"message": "Invalid request payload",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceLang := req.SourceLang
|
sourceLang := req.SourceLang
|
||||||
targetLang := req.TargetLang
|
targetLang := req.TargetLang
|
||||||
@ -208,10 +195,9 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
|
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Translation failed: %s", err)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"code": http.StatusInternalServerError,
|
"code": http.StatusInternalServerError,
|
||||||
"message": "Translation failed",
|
"message": "Translation failed: " + err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -265,10 +251,9 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
|
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Translation failed: %s", err)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"code": http.StatusInternalServerError,
|
"code": http.StatusInternalServerError,
|
||||||
"message": "Translation failed",
|
"message": "Translation failed: " + err.Error(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user