1
0
mirror of https://github.com/gogf/gf.git synced 2025-04-05 11:18:50 +08:00

fix(net/ghttp): remove unused code snippet (#4131)

This commit is contained in:
heansheng 2025-01-22 19:22:02 +08:00 committed by GitHub
parent 1f8845291a
commit f9c7eae23b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 19 deletions

View File

@ -183,7 +183,7 @@ func (r *Request) doGetRequestStruct(pointer interface{}, mapping ...map[string]
return data, nil return data, nil
} }
// `in` Tag Struct values. // `in` Tag Struct values.
if err = r.mergeInTagStructValue(data, pointer); err != nil { if err = r.mergeInTagStructValue(data); err != nil {
return data, nil return data, nil
} }
@ -239,7 +239,7 @@ func (r *Request) mergeDefaultStructValue(data map[string]interface{}, pointer i
} }
// mergeInTagStructValue merges the request parameters with header or cookie values from struct `in` tag definition. // mergeInTagStructValue merges the request parameters with header or cookie values from struct `in` tag definition.
func (r *Request) mergeInTagStructValue(data map[string]interface{}, pointer interface{}) error { func (r *Request) mergeInTagStructValue(data map[string]interface{}) error {
fields := r.serveHandler.Handler.Info.ReqStructFields fields := r.serveHandler.Handler.Info.ReqStructFields
if len(fields) > 0 { if len(fields) > 0 {
var ( var (

View File

@ -282,20 +282,3 @@ func createRouterFunc(funcInfo handlerFuncInfo) func(r *Request) {
} }
} }
} }
// trimGeneric removes type definitions string from response type name if generic
func trimGeneric(structName string) string {
var (
leftBraceIndex = strings.LastIndex(structName, "[") // for generic, it is faster to start at the end than at the beginning
rightBraceIndex = strings.LastIndex(structName, "]")
)
if leftBraceIndex == -1 || rightBraceIndex == -1 {
// not found '[' or ']'
return structName
} else if leftBraceIndex+1 == rightBraceIndex {
// may be a slice, because generic is '[X]', not '[]'
// to be compatible with bad return parameter type: []XxxRes
return structName
}
return structName[:leftBraceIndex]
}