Skip to content

Commit

Permalink
Merge pull request #21 from golang-acexy/develop
Browse files Browse the repository at this point in the history
upgrade lib
  • Loading branch information
acexy authored Jul 29, 2024
2 parents 41c1e20 + a3e944c commit c8e5b48
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 39 deletions.
4 changes: 2 additions & 2 deletions ginstarter/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"github.com/acexy/golang-toolkit/logger"
"github.com/acexy/golang-toolkit/math/conversion"
"github.com/acexy/golang-toolkit/util/slice"
coll "github.com/acexy/golang-toolkit/util/coll"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"net/http"
Expand Down Expand Up @@ -263,7 +263,7 @@ func MediaTypeMiddleware(contentType []string, match ...func(request *Request) b
}
}
if len(contentType) > 0 {
if !slice.Contains(contentType, request.GetHeader("Content-Type")) {
if !coll.SliceContains(contentType, request.GetHeader("Content-Type")) {
return RespAbortWithHttpStatusCode(http.StatusUnsupportedMediaType), false
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions ginstarter/validator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ginstarter

import (
"github.com/acexy/golang-toolkit/util/slice"
"github.com/acexy/golang-toolkit/util/coll"
"github.com/acexy/golang-toolkit/util/str"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -38,7 +38,7 @@ func friendlyValidatorMessage(errors validator.ValidationErrors) string {
builder.WriteString(str.LowFirstChar(vErr.Field()))
// 验证标签
tag := vErr.Tag()
if slice.Contains(typeDesc, tag) {
if coll.SliceContains(typeDesc, tag) {
builder.WriteString(" mismatch type ").WriteString(tag)
} else {
builder.WriteString(" ").WriteString(tag)
Expand Down
4 changes: 2 additions & 2 deletions ginstarter/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"errors"
"github.com/acexy/golang-toolkit/logger"
"github.com/acexy/golang-toolkit/util/slice"
"github.com/acexy/golang-toolkit/util/coll"
"github.com/gin-gonic/gin"
"net/http"
)
Expand Down Expand Up @@ -114,7 +114,7 @@ func (r *RouterWrapper) handler(methods []string, path string, contentType []str
}

if len(contentType) > 0 {
if !slice.Contains(contentType, context.GetHeader("Content-Type")) {
if !coll.SliceContains(contentType, context.GetHeader("Content-Type")) {
panic(&internalPanic{
statusCode: http.StatusUnsupportedMediaType,
rawError: errors.New(statusMessageMediaTypeNotAllowed),
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module github.com/golang-acexy/starter-gin
go 1.20

require (
github.com/acexy/golang-toolkit v0.0.18
github.com/acexy/golang-toolkit v0.0.19
github.com/gin-gonic/gin v1.10.0
github.com/go-playground/validator/v10 v10.22.0
github.com/golang-acexy/starter-parent v0.1.3
github.com/golang-acexy/starter-parent v0.1.4
github.com/sirupsen/logrus v1.9.3
)

require (
github.com/bytedance/sonic v1.11.9 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
Expand Down
37 changes: 8 additions & 29 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
github.com/acexy/golang-toolkit v0.0.14 h1:Aoz/PatuIDQ8j2lN4/vqcJNOE8mv85RcPsbhYsP9o5o=
github.com/acexy/golang-toolkit v0.0.14/go.mod h1:AHH70PoF5X9zXpAoBSBb4+kfeYPO/1tXOtONEu/QNlc=
github.com/acexy/golang-toolkit v0.0.15 h1:vHJliRqT1rPaxco+lffDWFSizyzRQBQJdlRQkqtYBuM=
github.com/acexy/golang-toolkit v0.0.15/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.16-0.20240710021726-532244e4599c h1:hfohuCxyq0eQWwdFU+SzsCmd2w3yA8VZ9mXvP9Mis2M=
github.com/acexy/golang-toolkit v0.0.16-0.20240710021726-532244e4599c/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.16 h1:dapLDm8LV8qdZusN8YpN3hCOn9+TX4QF8hS1B44cigA=
github.com/acexy/golang-toolkit v0.0.16/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.17-0.20240711025336-64ba05a2b5a4 h1:L+vCqNWPdcmEXK65tDXtnDnzOIgay2z0sbopXbNcJNg=
github.com/acexy/golang-toolkit v0.0.17-0.20240711025336-64ba05a2b5a4/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.17 h1:TF6U6BZwRjh5jbriQSPuJASYvdlgPPc9RJT6OmWSkak=
github.com/acexy/golang-toolkit v0.0.17/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.18 h1:tqDmzcZXmhsr9DKQo4Bb6MG7i9kOk/u709rBX6F93gY=
github.com/acexy/golang-toolkit v0.0.18/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/acexy/golang-toolkit v0.0.19 h1:kluUad/AbXWlj9DDzXyBSAkqALzJN5FRZg6AiN5V06o=
github.com/acexy/golang-toolkit v0.0.19/go.mod h1:ibyPO6K16k5eDjHlyU5Y+IhXeKWphQYMu2UPVkmoqfw=
github.com/bytedance/sonic v1.11.9 h1:LFHENlIY/SLzDWverzdOvgMztTxcfcF+cqNsz9pK5zg=
github.com/bytedance/sonic v1.11.9/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM=
github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
Expand All @@ -38,12 +27,8 @@ github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang-acexy/starter-parent v0.1.1 h1:KSf57ItnJfXhP9WZ6Yq9nRLzVsoWr8gOA4qS4CC3wiU=
github.com/golang-acexy/starter-parent v0.1.1/go.mod h1:lp09SvT0Rsd27M0Zpd+pzKIHjspvKnczAH0TxFfmFLA=
github.com/golang-acexy/starter-parent v0.1.2 h1:2zSUPw2YoDSBn4/RorYFSzsUeQgTOhtb+BFXnKs2hUI=
github.com/golang-acexy/starter-parent v0.1.2/go.mod h1:BAWVMIx5g6qgwrpGnll8Li1btOqY6SMcIcPNMnwFZB8=
github.com/golang-acexy/starter-parent v0.1.3 h1:ZeS8+EI0cSA5q4OdoKpGv/vy4TNjo7r1cirBtEyO2zo=
github.com/golang-acexy/starter-parent v0.1.3/go.mod h1:MVVE5bpXwRW3T9JNh/tsjVXE51APWGo9Rog88Uwal74=
github.com/golang-acexy/starter-parent v0.1.4 h1:sRPdX8Tebgui14O3oQg0lAG6Bw4HYy1WVvH5Cbfm8ko=
github.com/golang-acexy/starter-parent v0.1.4/go.mod h1:J7m0qZ9y9krOUoM2pkVW9dinf6rEqZ+qobADdwxcrvc=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down Expand Up @@ -86,19 +71,13 @@ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
Expand Down

0 comments on commit c8e5b48

Please sign in to comment.