From 99f5185cae597975e28ec7acd923a5c5169ce2a8 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 8 Oct 2024 20:36:59 +0800 Subject: [PATCH] feat(net/ghttp): remove Req/Res suffix limitation for strict router handler --- net/ghttp/ghttp_server_service_handler.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/net/ghttp/ghttp_server_service_handler.go b/net/ghttp/ghttp_server_service_handler.go index d7c2cac05cc..76de26aaae8 100644 --- a/net/ghttp/ghttp_server_service_handler.go +++ b/net/ghttp/ghttp_server_service_handler.go @@ -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())