Skip to content

Commit

Permalink
feat(core): ✨ add Headers module
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfoucrier committed May 5, 2023
1 parent a45bc26 commit 141249d
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions packages/core/src/modules/Headers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @barba/core/modules/headers
* <br><br>
* ## Manage request Headers.
*
* @module core/modules/headers
* @preferred
*/

/***/

export class Headers {
private _list: HeaderList = new Map([
['x-barba', 'yes'],
]);

/**
* Set a new header
*/
public set(name: string, value: string): IHeaderData {
this._list.set(name, value);

return {
name: value
};
}

/**
* Get a specific header
*/
public get(name: string): string {
return this._list.get(name);
}

/**
* Get all headers
*/
public all(): HeaderList {
return this._list;
}

/**
* Check if header exists
*/
public has(name: string): boolean {
return this._list.has(name);
}

/**
* Delete a header
*/
public delete(name: string): boolean {
return this._list.delete(name);
}

/**
* Clear all headers
*/
public clear(): void {
return this._list.clear();
}
}

0 comments on commit 141249d

Please sign in to comment.