mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
@ -197,6 +197,30 @@ func (s *Server) checkAndCreateFuncInfo(
|
||||
return
|
||||
}
|
||||
|
||||
if reflectType.In(1).Kind() != reflect.Ptr ||
|
||||
(reflectType.In(1).Kind() == reflect.Ptr && reflectType.In(1).Elem().Kind() != reflect.Struct) {
|
||||
err = gerror.NewCodef(
|
||||
gcode.CodeInvalidParameter,
|
||||
`invalid handler: defined as "%s", but the second input parameter should be type of pointer to struct like "*BizReq"`,
|
||||
reflectType.String(),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// Do not enable this logic, as many users are already using none struct pointer type
|
||||
// as the first output parameter.
|
||||
/*
|
||||
if reflectType.Out(0).Kind() != reflect.Ptr ||
|
||||
(reflectType.Out(0).Kind() == reflect.Ptr && reflectType.Out(0).Elem().Kind() != reflect.Struct) {
|
||||
err = gerror.NewCodef(
|
||||
gcode.CodeInvalidParameter,
|
||||
`invalid handler: defined as "%s", but the first output parameter should be type of pointer to struct like "*BizRes"`,
|
||||
reflectType.String(),
|
||||
)
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
// The request struct should be named as `xxxReq`.
|
||||
reqStructName := trimGeneric(reflectType.In(1).String())
|
||||
if !gstr.HasSuffix(reqStructName, `Req`) {
|
||||
|
||||
@ -391,7 +391,6 @@ func (c *Issue2890Controller) Post(ctx context.Context, req *Issue2890Req) (res
|
||||
// https://github.com/gogf/gf/issues/2890
|
||||
func Test_Issue2890(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
|
||||
oldEnumsJson, err := gtag.GetGlobalEnums()
|
||||
t.AssertNil(err)
|
||||
defer t.AssertNil(gtag.SetGlobalEnums(oldEnumsJson))
|
||||
@ -417,6 +416,7 @@ func Test_Issue2890(t *testing.T) {
|
||||
)
|
||||
t.Assert(
|
||||
c.PostContent(ctx, "/api/v2/issue2890", `{"Enums":"c"}`),
|
||||
"{\"code\":51,\"message\":\"The Enums value `c` should be in enums of: [\\\"a\\\",\\\"b\\\"]\",\"data\":null}")
|
||||
"{\"code\":51,\"message\":\"The Enums value `c` should be in enums of: [\\\"a\\\",\\\"b\\\"]\",\"data\":null}",
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user