(controllerPath string)
| 61 | } |
| 62 | |
| 63 | func (l *loader) loadController(controllerPath string) *Controller { |
| 64 | des, err := fs.ReadDir(l.fsys, controllerPath) |
| 65 | if err != nil { |
| 66 | l.Bail(err) |
| 67 | } else if len(des) == 0 { |
| 68 | l.Bail(fs.ErrNotExist) |
| 69 | } |
| 70 | controller := new(Controller) |
| 71 | controller.Path = l.loadControllerPath(controllerPath) |
| 72 | controller.Name = l.loadControllerName(controller.Path) |
| 73 | controller.Pascal = gotext.Pascal(controller.Name) |
| 74 | // TODO: rename to route |
| 75 | controller.Route = l.loadControllerRoute(controller.Path) |
| 76 | shouldParse := false |
| 77 | for _, de := range des { |
| 78 | if !de.IsDir() && valid.ControllerFile(de.Name()) { |
| 79 | shouldParse = true |
| 80 | continue |
| 81 | } |
| 82 | if de.IsDir() && valid.Dir(de.Name()) { |
| 83 | subController := l.loadController(path.Join(controllerPath, de.Name())) |
| 84 | if subController == nil { |
| 85 | continue |
| 86 | } |
| 87 | controller.Controllers = append(controller.Controllers, subController) |
| 88 | continue |
| 89 | } |
| 90 | } |
| 91 | if !shouldParse { |
| 92 | return controller |
| 93 | } |
| 94 | pkg, err := l.parser.Parse(controllerPath) |
| 95 | if err != nil { |
| 96 | l.Bail(err) |
| 97 | } |
| 98 | stct := pkg.Struct("Controller") |
| 99 | if stct == nil { |
| 100 | return controller |
| 101 | } |
| 102 | controller.Actions = l.loadActions(controller, stct) |
| 103 | return controller |
| 104 | } |
| 105 | |
| 106 | func (l *loader) loadControllerPath(controllerPath string) string { |
| 107 | parts := strings.SplitN(controllerPath, "/", 2) |
no test coverage detected