Skip to content

Commit

Permalink
unique version names in multiple versions' key API (#2812)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaochao8 authored Nov 20, 2023
1 parent ebdf534 commit b61ecc2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/v2/translation/handler_trans.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
package translation

import (
"io/ioutil"
"io"
"strings"

"sgtnserver/api"
"sgtnserver/internal/common"
"sgtnserver/internal/logger"
"sgtnserver/internal/sgtnerror"
"sgtnserver/modules/translation"
"sgtnserver/modules/translation/translationservice"
"strings"

"github.com/StudioSol/set"
"github.com/emirpasic/gods/sets/linkedhashset"
"github.com/gin-gonic/gin"
jsoniter "github.com/json-iterator/go"
Expand Down Expand Up @@ -311,6 +313,7 @@ func GetMultiVersionsKey(c *gin.Context) {
var versions []string
if params.Versions != api.AllVersions {
versions = strings.Split(params.Versions, common.ParamSep)
versions = set.NewLinkedHashSetString(versions...).AsSlice()
}

var result []interface{}
Expand Down Expand Up @@ -354,7 +357,7 @@ func GetStringByPost(c *gin.Context) {
}

if c.Request.Body != nil {
if bts, err := ioutil.ReadAll(c.Request.Body); err != nil {
if bts, err := io.ReadAll(c.Request.Body); err != nil {
api.AbortWithError(c, sgtnerror.StatusBadRequest.WrapErrorWithMessage(err, "fail to read request body"))
return
} else {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module sgtnserver
go 1.20

require (
github.com/StudioSol/set v1.0.0
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/anargu/gin-brotli v0.0.0-20220116052358-12bf532d5267
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6Xge
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/StudioSol/set v1.0.0 h1:G27J71la+Da08WidabBkoRrvPLTa4cdCn0RjvyJ5WKQ=
github.com/StudioSol/set v1.0.0/go.mod h1:hIUNZPo6rEGF43RlPXHq7Fjmf+HkVJBqAjtK7Z9LoIU=
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 h1:ZBbLwSJqkHBuFDA6DUhhse0IGJ7T5bemHyNILUjvOq4=
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2/go.mod h1:VSw57q4QFiWDbRnjdX8Cb3Ow0SFncRw+bA/ofY6Q83w=
github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
Expand Down

0 comments on commit b61ecc2

Please sign in to comment.