* Merge another code App instance into this app at the * specified path.
(path: string, app: App<State>)
| 355 | * specified path. |
| 356 | */ |
| 357 | mountApp(path: string, app: App<State>): this { |
| 358 | for (let i = 0; i < app.#commands.length; i++) { |
| 359 | const cmd = app.#commands[i]; |
| 360 | |
| 361 | if (cmd.type !== CommandType.App && cmd.type !== CommandType.NotFound) { |
| 362 | // Apply the inner app's basePath if it exists |
| 363 | let effectivePattern = cmd.pattern; |
| 364 | if (app.config.basePath) { |
| 365 | effectivePattern = mergePath(app.config.basePath, cmd.pattern, false); |
| 366 | } |
| 367 | |
| 368 | const clone = { |
| 369 | ...cmd, |
| 370 | pattern: mergePath(path, effectivePattern, true), |
| 371 | includeLastSegment: cmd.pattern === "/" || cmd.includeLastSegment, |
| 372 | }; |
| 373 | this.#commands.push(clone); |
| 374 | continue; |
| 375 | } |
| 376 | |
| 377 | this.#commands.push(cmd); |
| 378 | } |
| 379 | |
| 380 | // deno-lint-ignore no-this-alias |
| 381 | const self = this; |
| 382 | app.#getBuildCache = () => self.#getBuildCache(); |
| 383 | |
| 384 | return this; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Create handler function for `Deno.serve` or to be used in |