Skip to content

Commit

Permalink
feat(net/ghttp): remove Req/Res suffix limitation for strict router h…
Browse files Browse the repository at this point in the history
…andler
  • Loading branch information
gqcn committed Oct 8, 2024
1 parent 22773da commit 99f5185
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 99f5185

Please sign in to comment.