What `controller/method/$1` serves: the first run of segments that names a controller, then the method after it.
(root: string, uri: string, context: ResolutionContext)
| 217 | |
| 218 | /** What `controller/method/$1` serves: the first run of segments that names a controller, then the method after it. */ |
| 219 | function routeHandler(root: string, uri: string, context: ResolutionContext): Node | null { |
| 220 | const { controllers } = classTable(context); |
| 221 | const segments = uri.split('/').filter(Boolean); |
| 222 | const lower = segments.map((segment) => segment.toLowerCase()); |
| 223 | for (let i = lower.length; i > 0; i--) { |
| 224 | const classes = controllers.get(lower.slice(0, i).join('/')); |
| 225 | if (!classes) continue; |
| 226 | const cls = classes.find((c) => c.filePath.startsWith(root)) ?? classes[0]!; |
| 227 | return handlerIn(cls, segments, i, context); |
| 228 | } |
| 229 | return null; |
| 230 | } |
| 231 | |
| 232 | /** The file the `$this->load->view('users/list')` on this line loads: the caller's module's, another module's, or the app's. */ |
| 233 | function viewFile(ref: UnresolvedRef, context: ResolutionContext): Node | null { |