Skip to content

Commit

Permalink
feat(net/ghttp): remove Req/Res suffix limitation for input/output …
Browse files Browse the repository at this point in the history
…parameters of strict router handler (#3848)
  • Loading branch information
gqcn authored Nov 14, 2024
1 parent 955a76c commit 3d4904e
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions net/ghttp/ghttp_server_service_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,28 +221,6 @@ func (s *Server) checkAndCreateFuncInfo(
}
*/

// The request struct should be named as `xxxReq`.
reqStructName := trimGeneric(reflectType.In(1).String())
if !gstr.HasSuffix(reqStructName, `Req`) {
err = gerror.NewCodef(
gcode.CodeInvalidParameter,
`invalid struct naming for request: defined as "%s", but it should be named with "Req" suffix like "XxxReq"`,
reqStructName,
)
return
}

// The response struct should be named as `xxxRes`.
resStructName := trimGeneric(reflectType.Out(0).String())
if !gstr.HasSuffix(resStructName, `Res`) {
err = gerror.NewCodef(
gcode.CodeInvalidParameter,
`invalid struct naming for response: defined as "%s", but it should be named with "Res" suffix like "XxxRes"`,
resStructName,
)
return
}

funcInfo.IsStrictRoute = true

inputObject = reflect.New(funcInfo.Type.In(1).Elem())
Expand Down

0 comments on commit 3d4904e

Please sign in to comment.