Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
allow for passing of additional headers in kv.put requests (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham authored Feb 20, 2023
1 parent 5690794 commit 2a6da06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions wrapper/src/orbit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class OrbitConnection {
*
* @param key The key with which the object is indexed.
* @param value The value to be stored.
* @param req Optional request parameters.
* @param req Optional request parameters. Request Headers can be passed via the `headers` property.
* @returns A {@link Response} without the `data` property.
*/
async put(key: string, value: any, req?: Request): Promise<Response> {
Expand Down Expand Up @@ -77,8 +77,7 @@ export class OrbitConnection {
);
}

// @ts-ignore
return this.kv.put(key, blob, {}).then(transformResponse);
return this.kv.put(key, blob, req?.headers || {}).then(transformResponse);
}

/** Retrieve an object from the connected orbit.
Expand Down Expand Up @@ -232,6 +231,8 @@ export class OrbitConnection {
export type Request = {
/** Request to receive the data as a {@link https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream | ReadableStream}. */
streamBody?: boolean;
/** Add additional entries to the request HTTP Headers. */
headers?: { [key: string]: string };
};

/** Response from kepler requests.
Expand Down

0 comments on commit 2a6da06

Please sign in to comment.