@shopify/react-network
Version:
A collection of components that allow you to set common HTTP headers from within your React application
40 lines • 1.45 kB
TypeScript
/// <reference types="node" />
import type { IncomingHttpHeaders } from 'http';
import type { CspDirective } from '@shopify/network';
import { StatusCode } from '@shopify/network';
import type { EffectKind } from '@shopify/react-effect';
import type { Cookie } from './ServerCookieManager';
import { ServerCookieManager } from './ServerCookieManager';
export { NetworkContext } from './context';
export declare const EFFECT_ID: unique symbol;
interface Options {
headers?: {
[key: string]: string;
} | IncomingHttpHeaders;
cookies?: Cookie | string;
}
export declare class NetworkManager {
readonly effect: EffectKind;
cookies: ServerCookieManager;
private statusCodes;
private redirectUrl?;
private readonly csp;
private readonly headers;
private readonly requestHeaders;
constructor({ headers, cookies }?: Options);
reset(): void;
getHeader(header: string): string;
setHeader(header: string, value: string): void;
redirectTo(url: string, status?: StatusCode): void;
addStatusCode(statusCode: StatusCode): void;
addCspDirective(directive: CspDirective, value: string | string[] | boolean): void;
extract(): {
status: number | undefined;
headers: Map<string, string>;
cookies: {
[x: string]: import("./ServerCookieManager").CookieValue;
};
redirectUrl: string | undefined;
};
}
//# sourceMappingURL=manager.d.ts.map