Stop recursive loop where its a recursive type
This commit is contained in:
parent
4f15d823c9
commit
3dd911fb33
@ -20,7 +20,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractValue(v reflect.Type) *registry.Value {
|
func extractValue(v reflect.Type, d int) *registry.Value {
|
||||||
|
if d == 3 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -37,7 +40,10 @@ func extractValue(v reflect.Type) *registry.Value {
|
|||||||
switch v.Kind() {
|
switch v.Kind() {
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
for i := 0; i < v.NumField(); i++ {
|
for i := 0; i < v.NumField(); i++ {
|
||||||
val := extractValue(v.Field(i).Type)
|
val := extractValue(v.Field(i).Type, d+1)
|
||||||
|
if val == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
val.Name = v.Field(i).Name
|
val.Name = v.Field(i).Name
|
||||||
arg.Values = append(arg.Values, val)
|
arg.Values = append(arg.Values, val)
|
||||||
}
|
}
|
||||||
@ -47,7 +53,10 @@ func extractValue(v reflect.Type) *registry.Value {
|
|||||||
p = p.Elem()
|
p = p.Elem()
|
||||||
}
|
}
|
||||||
arg.Type = "[]" + p.Name()
|
arg.Type = "[]" + p.Name()
|
||||||
arg.Values = append(arg.Values, extractValue(v.Elem()))
|
val := extractValue(v.Elem(), d+1)
|
||||||
|
if val != nil {
|
||||||
|
arg.Values = append(arg.Values, val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return arg
|
return arg
|
||||||
@ -77,8 +86,8 @@ func extractEndpoint(method reflect.Method) *registry.Endpoint {
|
|||||||
stream = true
|
stream = true
|
||||||
}
|
}
|
||||||
|
|
||||||
request := extractValue(reqType)
|
request := extractValue(reqType, 0)
|
||||||
response := extractValue(rspType)
|
response := extractValue(rspType, 0)
|
||||||
|
|
||||||
return ®istry.Endpoint{
|
return ®istry.Endpoint{
|
||||||
Name: method.Name,
|
Name: method.Name,
|
||||||
@ -102,7 +111,7 @@ func extractSubValue(typ reflect.Type) *registry.Value {
|
|||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return extractValue(reqType)
|
return extractValue(reqType, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractAddress(addr string) (string, error) {
|
func extractAddress(addr string) (string, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user