diff --git a/a2r/api2rpc.go b/a2r/api2rpc.go index 218bc04..11f264c 100644 --- a/a2r/api2rpc.go +++ b/a2r/api2rpc.go @@ -35,7 +35,7 @@ type Option[A, B any] struct { RespAfter func(*B) error } -func Call[A, B, C any](rpc func(client C, ctx context.Context, req *A, options ...grpc.CallOption) (*B, error), client C, c *gin.Context, opts ...*Option[A, B]) { +func Call[A, B, C any](c *gin.Context, rpc func(client C, ctx context.Context, req *A, options ...grpc.CallOption) (*B, error), client C, opts ...*Option[A, B]) { req, err := ParseRequestNotCheck[A](c) if err != nil { apiresp.GinError(c, err) diff --git a/a2r/call_v2.go b/a2r/call_v2.go deleted file mode 100644 index 193eae7..0000000 --- a/a2r/call_v2.go +++ /dev/null @@ -1,46 +0,0 @@ -package a2r - -import ( - "context" - - "github.com/gin-gonic/gin" - "github.com/openimsdk/tools/apiresp" - "github.com/openimsdk/tools/checker" - "google.golang.org/grpc" -) - -func CallV2[A, B any](c *gin.Context, rpc func(ctx context.Context, req *A, options ...grpc.CallOption) (*B, error), opts ...*Option[A, B]) { - req, err := ParseRequestNotCheck[A](c) - if err != nil { - apiresp.GinError(c, err) - return - } - for _, opt := range opts { - if opt.BindAfter == nil { - continue - } - if err := opt.BindAfter(req); err != nil { - apiresp.GinError(c, err) // args option error - return - } - } - if err := checker.Validate(req); err != nil { - apiresp.GinError(c, err) // args option error - return - } - resp, err := rpc(c, req) - if err != nil { - apiresp.GinError(c, err) // rpc call failed - return - } - for _, opt := range opts { - if opt.RespAfter == nil { - continue - } - if err := opt.RespAfter(resp); err != nil { - apiresp.GinError(c, err) // resp option error - return - } - } - apiresp.GinSuccess(c, resp) // rpc call success -} diff --git a/a2r/option.go b/a2r/option.go index fa83cd7..4075c97 100644 --- a/a2r/option.go +++ b/a2r/option.go @@ -17,5 +17,3 @@ func respNilReplace[T any](data *T) error { mw.ReplaceNil(data) return nil } - -// ------------------------------------------------------------------------------------------------------------------