-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/ssr): dynamic route resolution using Angular router
This enhancement eliminates the dependency on file extensions for server-side rendering (SSR) route handling, leveraging Angular's router configuration for more dynamic and flexible route determination. Additionally, configured redirectTo routes now correctly respond with a 302 redirect status. The new router uses a radix tree for storing routes. This data structure allows for efficient prefix-based lookups and insertions, which is particularly crucial when dealing with nested and parameterized routes. This change also lays the groundwork for potential future server-side routing configurations, further enhancing the capabilities of Angular's SSR functionality.
- Loading branch information
1 parent
37693c4
commit bca5683
Showing
22 changed files
with
1,353 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import { AngularAppManifest } from './manifest'; | ||
|
||
/** | ||
* Manages server-side assets. | ||
*/ | ||
export class ServerAssets { | ||
/** | ||
* Creates an instance of ServerAsset. | ||
* | ||
* @param manifest - The manifest containing the server assets. | ||
*/ | ||
constructor(private readonly manifest: AngularAppManifest) {} | ||
|
||
/** | ||
* Retrieves the content of a server-side asset using its path. | ||
* | ||
* @param path - The path to the server asset. | ||
* @returns A promise that resolves to the asset content as a string. | ||
* @throws Error If the asset path is not found in the manifest, an error is thrown. | ||
*/ | ||
async getServerAsset(path: string): Promise<string> { | ||
const asset = this.manifest.assets[path]; | ||
if (!asset) { | ||
throw new Error(`Server asset '${path}' does not exist.`); | ||
} | ||
|
||
return asset(); | ||
} | ||
|
||
/** | ||
* Retrieves and caches the content of 'index.server.html'. | ||
* | ||
* @returns A promise that resolves to the content of 'index.server.html'. | ||
* @throws Error If there is an issue retrieving the asset. | ||
*/ | ||
getIndexServerHtml(): Promise<string> { | ||
return this.getServerAsset('index.server.html'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.