mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 23:07:51 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2438d72d3f | ||
|
|
e74d34e7ab |
+2
-5
@@ -6,8 +6,5 @@ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx .
|
|||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN addgroup -S deeplx && adduser -h /app -G deeplx -SH deeplx
|
COPY --from=builder /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
||||||
USER deeplx:deeplx
|
CMD ["/app/deeplx"]
|
||||||
COPY --from=builder --chown=deeplx:deeplx /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
|
||||||
EXPOSE 1188
|
|
||||||
ENTRYPOINT ["/app/deeplx"]
|
|
||||||
|
|||||||
+5
-32
@@ -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,12 +127,7 @@ 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)
|
log.Fatalf("Translation failed: %s", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"code": http.StatusInternalServerError,
|
|
||||||
"message": "Translation failed",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.Code == http.StatusOK {
|
if result.Code == http.StatusOK {
|
||||||
@@ -163,13 +152,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,12 +191,7 @@ 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)
|
log.Fatalf("Translation failed: %s", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"code": http.StatusInternalServerError,
|
|
||||||
"message": "Translation failed",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.Code == http.StatusOK {
|
if result.Code == http.StatusOK {
|
||||||
@@ -265,12 +243,7 @@ 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)
|
log.Fatalf("Translation failed: %s", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"code": http.StatusInternalServerError,
|
|
||||||
"message": "Translation failed",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.Code == http.StatusOK {
|
if result.Code == http.StatusOK {
|
||||||
|
|||||||
Reference in New Issue
Block a user