MCPcopy Index your code
hub / github.com/angular/angular-cli / handle

Method handle

packages/angular/ssr/src/app.ts:179–218  ·  view source on GitHub ↗

* Handles an incoming HTTP request by serving prerendered content, performing server-side rendering, * or delivering a static file for client-side rendered routes based on the `RenderMode` setting. * * @param request - The HTTP request to handle. * @param requestContext - Optional contex

(request: Request, requestContext?: unknown)

Source from the content-addressed store, hash-verified

177 * corresponding to `https://www.example.com/page`.
178 */
179 async handle(request: Request, requestContext?: unknown): Promise<Response | null> {
180 const url = new URL(request.url);
181 if (WELL_KNOWN_NON_ANGULAR_URLS.has(url.pathname)) {
182 return null;
183 }
184
185 this.router ??= await ServerRouter.from(this.manifest, url);
186 const matchedRoute = this.router.match(url);
187
188 if (!matchedRoute) {
189 // Not a known Angular route.
190 return null;
191 }
192
193 const { redirectTo, status, renderMode, headers } = matchedRoute;
194
195 if (redirectTo !== undefined) {
196 return createRedirectResponse(
197 joinUrlParts(
198 request.headers.get('X-Forwarded-Prefix') ?? '',
199 buildPathWithParams(redirectTo, url.pathname),
200 ),
201 status,
202 headers,
203 );
204 }
205
206 if (renderMode === RenderMode.Prerender) {
207 const response = await this.handleServe(request, matchedRoute);
208 if (response) {
209 return response;
210 }
211 }
212
213 return promiseWithAbort(
214 this.handleRendering(request, matchedRoute, requestContext),
215 request.signal,
216 `Request for: ${request.url}`,
217 );
218 }
219
220 /**
221 * Handles serving a prerendered static asset if available for the matched route.

Callers 2

app-engine_spec.tsFile · 0.45
app_spec.tsFile · 0.45

Calls 10

handleServeMethod · 0.95
handleRenderingMethod · 0.95
createRedirectResponseFunction · 0.90
joinUrlPartsFunction · 0.90
buildPathWithParamsFunction · 0.90
promiseWithAbortFunction · 0.90
fromMethod · 0.80
hasMethod · 0.65
getMethod · 0.65
matchMethod · 0.45

Tested by

no test coverage detected