Skip to content

Commit

Permalink
Merge pull request #13 from origadmin/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
godcong authored Dec 6, 2024
2 parents 0de1720 + 1d621ce commit a6a56d2
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 168 deletions.
18 changes: 15 additions & 3 deletions tools/protoc-gen-go-ginrpc/ginrpc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
const {{$svrType}}_{{.OriginalName}}_FullOperation = "/{{$svrName}}/{{.OriginalName}}"
{{- end}}

type {{.ServiceType}}GINRPCAgentResponder interface {
// Error returns a error
Error(*gins.Context, int, error) error
// JSON returns a json data
JSON(*gins.Context, int, any) error
// Any returns errors or any data
Any(*gins.Context, int, any, error) error
}

type {{.ServiceType}}GINRPCAgent interface {
{{.ServiceType}}GINRPCAgentResponder
{{- range.MethodSets}}
{{- if ne .Comment ""}}
{{.Comment}}
Expand All @@ -26,17 +38,17 @@ func Register{{.ServiceType}}GINRPCAgent (router gins.IRouter, srv {{.ServiceTyp
var in {{.Request}}
{{- if.HasBody}}
if err := gins.BindBody(ctx,&in{{.Body}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- end}}
if err := gins.BindQuery(ctx,&in{{.Query}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- if.HasVars}}
if err := gins.BindURI(ctx,&in{{.Vars}}); err != nil {
gins.ResultError(ctx,err)
srv.Error(ctx, 400, err)
return
}
{{- end}}
Expand Down
10 changes: 5 additions & 5 deletions tools/protoc-gen-go-gins/gins.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ func Register{{.ServiceType}}GINSServer(router gins.IRouter, srv {{.ServiceType}
var in {{.Request}}
{{- if.HasBody}}
if err := gins.BindBody(ctx,&in{{.Body}}); err != nil {
gins.ResultError(ctx,err)
gins.JSON(ctx,400,err)
return
}
{{- end}}
if err := gins.BindQuery(ctx,&in{{.Query}}); err != nil {
gins.ResultError(ctx,err)
gins.JSON(ctx,400,err)
return
}
{{- if.HasVars}}
if err := gins.BindURI(ctx,&in{{.Vars}}); err != nil {
gins.ResultError(ctx,err)
gins.JSON(ctx,400,err)
return
}
{{- end}}
gins.SetOperation(ctx, {{$svrType}}_{{.OriginalName}}_OperationName)
newCtx := gins.NewContext(ctx)
reply, err := srv.{{.Name}}(newCtx, &in)
if err != nil {
gins.ResultError(ctx,err)
gins.JSON(ctx,500,err)
return
}
gins.ResultJSON(ctx,200, reply{{.ResponseBody}})
gins.JSON(ctx,200, reply{{.ResponseBody}})
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/protoc-gen-go-gins/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/origadmin/contrib/tools/protoc-gen-go-gins
go 1.23.1

require (
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28
google.golang.org/protobuf v1.35.1
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583
google.golang.org/protobuf v1.35.2
)
4 changes: 4 additions & 0 deletions tools/protoc-gen-go-gins/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g=
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4=
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583 h1:v+j+5gpj0FopU0KKLDGfDo9ZRRpKdi5UBrCP0f76kuY=
google.golang.org/genproto/googleapis/api v0.0.0-20241206012308-a4fef0638583/go.mod h1:jehYqy3+AhJU9ve55aNOaSml7wUXjF9x6z2LcCfpAhY=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
6 changes: 3 additions & 3 deletions transport/gins/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func NewContext(ctx *gin.Context) context.Context {
}

// FromContext takes a context as an argument and returns a pointer to a gin.Context and a boolean value.
func FromContext(ctx context.Context) (*gin.Context, bool) {
func FromContext(ctx context.Context) *gin.Context {
// Check if the context contains a value of type *gin.Context
if v, ok := ctx.Value(ginCtx{}).(*gin.Context); ok {
// If the context contains a value of type *gin.Context, return the value and true
return v, true
return v
}
// If the context does not contain a value of type *gin.Context, return nil and false
return nil, false
return nil
}
22 changes: 11 additions & 11 deletions transport/gins/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ toolchain go1.23.2
require (
github.com/gin-gonic/gin v1.10.0
github.com/go-kratos/kratos/v2 v2.8.2
github.com/goexts/generic v0.1.1
github.com/gorilla/mux v1.8.1
github.com/origadmin/runtime v0.0.1
github.com/origadmin/toolkits v0.1.3
github.com/origadmin/toolkits/errors v0.0.11
github.com/origadmin/runtime v0.0.10
github.com/origadmin/toolkits/errors v0.0.17
google.golang.org/protobuf v1.35.2
)

Expand All @@ -20,6 +18,7 @@ require (
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
Expand All @@ -40,15 +39,16 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.12.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/grpc v1.68.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
google.golang.org/grpc v1.68.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
42 changes: 18 additions & 24 deletions transport/gins/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ github.com/go-playground/validator/v10 v10.23.0 h1:/PwmTwZhS0dPkav3cdK9kV1FsAmrL
github.com/go-playground/validator/v10 v10.23.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/goexts/generic v0.1.1 h1:dg5aPYVoH9MzdfRLngOVwb6Ws7dR6q1/BJeoVm3fO9k=
github.com/goexts/generic v0.1.1/go.mod h1:j/ZjWHYt+If6VjeHWvDhYKdoP+gAiAKpm0cu3yvKmfo=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
Expand Down Expand Up @@ -70,12 +68,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/origadmin/runtime v0.0.1 h1:SqgVbD4k/xgviItdYBxyWLSx0euWsuwxLp36fEr31Uk=
github.com/origadmin/runtime v0.0.1/go.mod h1:qjKsw3rZoT+/uhjEvQzUjdUK2CjU9I5RmbXDI962V8E=
github.com/origadmin/toolkits v0.1.3 h1:5nqpc34FiobpsQBQj/HLYMJCA7+A7G5TzAzxhmb2P2c=
github.com/origadmin/toolkits v0.1.3/go.mod h1:+BZ3uvvrsJIqRMbga6zalMinuTldHut/yaJbvVW4994=
github.com/origadmin/toolkits/errors v0.0.11 h1:0V0HcCrnhnHxNX8LgZpASYtnWZfpxBph0x9fCV01+Ko=
github.com/origadmin/toolkits/errors v0.0.11/go.mod h1:6DM+lY0GU/UWobF66Fh/zeLJl3zF6Ll9+8ujHjSCwFQ=
github.com/origadmin/runtime v0.0.10 h1:CMSFYoVQd6hG1dAdCXrL6mD8S0mFr5Lz9ewgP8gH7oE=
github.com/origadmin/runtime v0.0.10/go.mod h1:TTGjMpsjyguUQJnyT5LGb0Iz+eYYAws97SiDbYtwFjY=
github.com/origadmin/toolkits/errors v0.0.17 h1:5yu5tUOxPggrz+yCOoH7/W1HaoM/B8Zp5AuUBtu1LiY=
github.com/origadmin/toolkits/errors v0.0.17/go.mod h1:6DM+lY0GU/UWobF66Fh/zeLJl3zF6Ll9+8ujHjSCwFQ=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -101,23 +97,21 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg=
golang.org/x/arch v0.12.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 h1:IfdSdTcLFy4lqUQrQJLkLt1PB+AsqVz6lwkWPzWEz10=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0=
google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
17 changes: 5 additions & 12 deletions transport/gins/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,15 @@ import (
func Logger(logger log.Logger) HandlerFunc {
return func(c *Context) {
start := time.Now()
path := c.Request.URL.Path
query := c.Request.URL.RawQuery
c.Next()
//"status": c.Writer.Status(),
// "method": c.Request.Method,
// "path": path,
// "ip": c.ClientIP(),
// "latency": latency,
// "user-agent": c.Request.UserAgent(),
// "time": end.Format(timeFormat),
cost := time.Since(start)
_ = logger.Log(log.LevelInfo,

_ = logger.Log(
log.LevelInfo,
"status", c.Writer.Status(),
"method", c.Request.Method,
"path", path,
"query", query,
"path", c.Request.URL.Path,
"query", c.Request.URL.RawQuery,
"ip", c.ClientIP(),
"user-agent", c.Request.UserAgent(),
"errors", c.Errors.ByType(ErrorTypePrivate).String(),
Expand Down
3 changes: 0 additions & 3 deletions transport/gins/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ func Address(addr string) ServerOption {

func StrictSlash(strictSlash bool) ServerOption {
return func(s *Server) {
if s.engine == nil {
s.engine = New()
}
s.engine.RedirectTrailingSlash = strictSlash
}
}
Expand Down
117 changes: 14 additions & 103 deletions transport/gins/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,116 +6,27 @@
package gins

import (
"encoding/json"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
"github.com/goexts/generic/maps"
"github.com/origadmin/runtime/context"
"github.com/origadmin/toolkits/errors"
"github.com/origadmin/toolkits/errors/httperr"
"github.com/origadmin/toolkits/net/pagination"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)

type Result struct {
pagination.UnimplementedResponder `json:"-"`
Success bool `json:"success"`
Total int32 `json:"total,omitempty"`
Data any `json:"data,omitempty"`
Extra any `json:"extra,omitempty"`
Error *httperr.Error `json:"error,omitempty"`
}

func (r Result) GetData() any {
return r.Data
}
var mo = protojson.MarshalOptions{}

func (r Result) GetSuccess() bool {
return r.Success
}

var protoOption = protojson.MarshalOptions{
EmitDefaultValues: true,
}

// ResultJSON result json data with status code
func ResultJSON(c *gin.Context, status int, data any) {
var buf []byte
var err error
// JSON result json data with status code
func JSON(c *gin.Context, status int, data any) {
if msg, ok := data.(proto.Message); ok {
buf, err = protoOption.Marshal(msg)
} else {
buf, err = json.Marshal(data)
}
if err != nil {
panic(err)
buf, err := mo.Marshal(msg)
if err != nil {
c.Error(errors.Wrap(err, "marshal proto message error"))
return
}
c.Set(ContextResponseBodBytesKey, buf)
c.Data(status, "application/json; charset=utf-8", buf)
c.Abort()
return
}

c.Set(ContextResponseBodBytesKey, buf)
c.Data(status, "application/json; charset=utf-8", buf)
c.Abort()
}

// ResultSuccess result success data with status code
func ResultSuccess(c *gin.Context, resp pagination.Responder) {
ResultJSON(c, http.StatusOK, Result{
Success: true,
Data: resp.GetData(),
})
}

// ResultOK result success data with status code
func ResultOK(c *gin.Context) {
ResultJSON(c, http.StatusOK, Result{
Success: true,
})
}

// ResultPage result page data with status code
func ResultPage(c *gin.Context, resp pagination.Responder, args ...map[string]any) {
extra := resp.GetExtra()
if extra == nil && len(args) > 0 {
maps.MergeMaps(args[0], args[1:]...)
extra = args[0]
}
ResultJSON(c, http.StatusOK, Result{
Success: true,
Data: resp.GetData(),
Extra: extra,
Total: resp.GetTotal(),
})
}

// ResultError result error data with status code
func ResultError(c *Context, err error, status ...int) {
var ierr *httperr.Error
if ok := errors.As(err, &ierr); !ok {
ierr = httperr.FromError(httperr.InternalServerError(err.Error())) // default error
}

code := int(ierr.Code)
if len(status) > 0 {
code = status[0]
}

if code >= 500 {
ctx := c.Request.Context()
//ctx = context.NewTag(ctx, logging.TagKeySystem)
ctx = context.NewStack(ctx, fmt.Sprintf("%+v", err))
//logging.Context(ctx).LogAttrs(ctx, slog.LevelError, "Internal server error", slog.Any("error", err))
ierr.Detail = http.StatusText(http.StatusInternalServerError)
}

ierr.Code = int32(code)
_ = c.Error(gin.Error{
Err: ierr,
Type: gin.ErrorTypeAny,
Meta: c.Request.URL.RawQuery,
})
ResultJSON(c, code, Result{
Error: ierr,
})
c.JSON(status, data)
return
}
Loading

0 comments on commit a6a56d2

Please sign in to comment.