|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.dev/license |
| 7 | + */ |
| 8 | + |
| 9 | +import {InjectionToken} from '../di/injection_token'; |
| 10 | + |
| 11 | +/** |
| 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 | + * |
| 27 | + * @developerPreview |
| 28 | + */ |
| 29 | +export const REQUEST = new InjectionToken<Request | null>('REQUEST', { |
| 30 | + providedIn: 'platform', |
| 31 | + factory: () => null, |
| 32 | +}); |
| 33 | + |
| 34 | +/** |
| 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 | + * |
| 50 | + * @developerPreview |
| 51 | + */ |
| 52 | +export const RESPONSE_INIT = new InjectionToken<ResponseInit | null>('RESPONSE_INIT', { |
| 53 | + providedIn: 'platform', |
| 54 | + factory: () => null, |
| 55 | +}); |
| 56 | + |
| 57 | +/** |
| 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 | + * |
| 65 | + * @developerPreview |
| 66 | + */ |
| 67 | +export const REQUEST_CONTEXT = new InjectionToken<unknown>('REQUEST_CONTEXT', { |
| 68 | + providedIn: 'platform', |
| 69 | + factory: () => null, |
| 70 | +}); |
0 commit comments