UNPKG

@riddance/host

Version:

30 lines (29 loc) 992 B
import { Context } from '../context.js'; import type { Json } from '../http.js'; import { ClientInfo, RootLogger } from './context.js'; import type { HttpHandler } from './registry.js'; export type Response = { headers: { readonly [key: string]: string; }; status: number; body?: string | Buffer; }; type RequestOptions = BodylessRequestOptions | StringRequestOptions | JsonRequestOptions; type BodylessRequestOptions = { uri: string; headers?: { readonly [key: string]: string; }; }; type StringRequestOptions = BodylessRequestOptions & { body: string; }; type JsonRequestOptions = BodylessRequestOptions & { json: Json; }; export declare function executeRequest(log: RootLogger, context: Omit<Context, 'log'>, handler: HttpHandler, options: RequestOptions, success: () => Promise<unknown>): Promise<Response>; export declare function clientFromHeaders(headers: { readonly [key: string]: string; } | undefined): ClientInfo; export {};