From bb14fe86e31fbb80daaa3898499f93d0e4ebc1f7 Mon Sep 17 00:00:00 2001 From: Matthieu Riegler Date: Mon, 3 Mar 2025 17:19:34 +0100 Subject: [PATCH] refactor(http): add `context` property to `httpResource` (#60188) This was an oversight, `context` can be supported out of the box. PR Close #60188 --- goldens/public-api/common/http/index.api.md | 1 + packages/common/http/src/resource_api.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/goldens/public-api/common/http/index.api.md b/goldens/public-api/common/http/index.api.md index ba335014e62..e57fec51f3b 100644 --- a/goldens/public-api/common/http/index.api.md +++ b/goldens/public-api/common/http/index.api.md @@ -1741,6 +1741,7 @@ export interface HttpResourceRef extends WritableResource, ResourceRef // @public export interface HttpResourceRequest { body?: unknown; + context?: HttpContext; headers?: HttpHeaders | Record>; method?: string; params?: HttpParams | Record>; diff --git a/packages/common/http/src/resource_api.ts b/packages/common/http/src/resource_api.ts index 3b5219a35a6..e345aba24dc 100644 --- a/packages/common/http/src/resource_api.ts +++ b/packages/common/http/src/resource_api.ts @@ -10,6 +10,7 @@ import type {Injector, ResourceRef, Signal, ValueEqualityFn, WritableResource} f import type {HttpHeaders} from './headers'; import type {HttpParams} from './params'; import type {HttpProgressEvent} from './response'; +import {HttpContext} from './context'; /** * The structure of an `httpResource` request which will be sent to the backend. @@ -50,6 +51,11 @@ export interface HttpResourceRequest { */ headers?: HttpHeaders | Record>; + /** + * Context of the request stored in a dictionary of key-value pairs. + */ + context?: HttpContext; + /** * If `true`, progress events will be enabled for the request and delivered through the * `HttpResource.progress` signal.