|
9 | 9 | import { InjectionToken } from '@angular/core';
|
10 | 10 |
|
11 | 11 | /**
|
12 |
| - * Injection token for the current request. |
| 12 | + * Injection token representing the current HTTP request object. |
| 13 | + * |
| 14 | + * Use this token to access the current request when handling server-side |
| 15 | + * rendering (SSR). |
| 16 | + * |
| 17 | + * @remarks |
| 18 | + * This token may be `null` in the following scenarios: |
| 19 | + * |
| 20 | + * * During the build processes. |
| 21 | + * * When the application is rendered in the browser (client-side rendering). |
| 22 | + * * When performing static site generation (SSG). |
| 23 | + * * During route extraction in development (at the time of the request). |
| 24 | + * |
| 25 | + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | `Request` on MDN} |
| 26 | + * |
13 | 27 | * @developerPreview
|
14 | 28 | */
|
15 |
| -export const REQUEST = new InjectionToken<Request>('REQUEST'); |
| 29 | +export const REQUEST = new InjectionToken<Request | null>('REQUEST', { |
| 30 | + providedIn: 'platform', |
| 31 | + factory: () => null, |
| 32 | +}); |
16 | 33 |
|
17 | 34 | /**
|
18 |
| - * Injection token for the response initialization options. |
| 35 | + * Injection token for response initialization options. |
| 36 | + * |
| 37 | + * Use this token to provide response options for configuring or initializing |
| 38 | + * HTTP responses in server-side rendering or API endpoints. |
| 39 | + * |
| 40 | + * @remarks |
| 41 | + * This token may be `null` in the following scenarios: |
| 42 | + * |
| 43 | + * * During the build processes. |
| 44 | + * * When the application is rendered in the browser (client-side rendering). |
| 45 | + * * When performing static site generation (SSG). |
| 46 | + * * During route extraction in development (at the time of the request). |
| 47 | + * |
| 48 | + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/Response | `ResponseInit` on MDN} |
| 49 | + * |
19 | 50 | * @developerPreview
|
20 | 51 | */
|
21 |
| -export const RESPONSE_INIT = new InjectionToken<ResponseInit>('RESPONSE_INIT'); |
| 52 | +export const RESPONSE_INIT = new InjectionToken<ResponseInit | null>('RESPONSE_INIT', { |
| 53 | + providedIn: 'platform', |
| 54 | + factory: () => null, |
| 55 | +}); |
22 | 56 |
|
23 | 57 | /**
|
24 | 58 | * Injection token for additional request context.
|
| 59 | + * |
| 60 | + * Use this token to pass custom metadata or context related to the current request in server-side rendering. |
| 61 | + * |
| 62 | + * @remarks |
| 63 | + * This token is only available during server-side rendering and will be `null` in other contexts. |
| 64 | + * |
25 | 65 | * @developerPreview
|
26 | 66 | */
|
27 |
| -export const REQUEST_CONTEXT = new InjectionToken<unknown>('REQUEST_CONTEXT'); |
| 67 | +export const REQUEST_CONTEXT = new InjectionToken<unknown>('REQUEST_CONTEXT', { |
| 68 | + providedIn: 'platform', |
| 69 | + factory: () => null, |
| 70 | +}); |
0 commit comments