Load the inner fields of the result type, if it's a struct
(result *parser.Result, def parser.Declaration)
| 416 | |
| 417 | // Load the inner fields of the result type, if it's a struct |
| 418 | func (l *loader) loadActionResultFields(result *parser.Result, def parser.Declaration) (fields []*ActionResultField) { |
| 419 | // Fields should be empty if the definition isn't a struct |
| 420 | if def.Kind() != parser.KindStruct { |
| 421 | return fields |
| 422 | } |
| 423 | // Find the struct in the package |
| 424 | stct := def.Package().Struct(def.Name()) |
| 425 | if stct == nil { |
| 426 | l.Bail(fmt.Errorf("controller: unable to find struct for %s", result.Type())) |
| 427 | } |
| 428 | for _, field := range stct.PublicFields() { |
| 429 | fields = append(fields, &ActionResultField{ |
| 430 | Name: field.Name(), |
| 431 | Type: field.Type().String(), |
| 432 | }) |
| 433 | } |
| 434 | return fields |
| 435 | } |
| 436 | |
| 437 | // TODO: Clean this up, the logic is quite complicated and could be simplified |
| 438 | // with better methods |
no test coverage detected