UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

52 lines • 1.95 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseTraces = /* @__PURE__ */ (() => { class BaseTraces extends APIResource { /** * Traces a simulated HTTP request through Cloudflare's edge to analyze how rules, * settings, and configurations would process the request. Useful for debugging * firewall rules, page rules, and other request transformations without sending * actual traffic. Supports custom headers, cookies, body content, and geolocation * context. * * @example * ```ts * const trace = await client.requestTracers.traces.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * method: 'PUT', * url: 'https://some.zone/some_path', * body: { base64: 'c29tZV9yZXF1ZXN0X2JvZHk=' }, * context: { * geoloc: { city: 'London' }, * skip_challenge: true, * }, * cookies: { * cookie_name_1: 'cookie_value_1', * cookie_name_2: 'cookie_value_2', * }, * headers: { * header_name_1: 'header_value_1', * header_name_2: 'header_value_2', * }, * protocol: 'HTTP/1.1', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/request-tracer/trace`, { body, ...options, })._thenUnwrap((obj) => obj.result); } } BaseTraces._key = Object.freeze([ 'requestTracers', 'traces', ]); return BaseTraces; })(); export class Traces extends BaseTraces { } //# sourceMappingURL=traces.mjs.map