Liking cljdoc? Tell your friends :D

com.heavycomputation.cloudflare.internal.api

A tiny, zero-dependency client for the Cloudflare REST API v4: attaches a Bearer token and sends requests over the JDK's java.net.http client. It is the transport the Images product needs — the counterpart to internal.s3, but for Cloudflare's own JSON API rather than S3.

It handles two request-body shapes, both hand-rolled so nothing is pulled in: a JSON body (:json <clj-data>) and a multipart/form-data upload (:multipart [part …]). It is stateless and carries no per-product knowledge; callers build paths and interpret responses.

A tiny, zero-dependency client for the Cloudflare REST API v4: attaches a
Bearer token and sends requests over the JDK's `java.net.http` client. It is
the transport the Images product needs — the counterpart to `internal.s3`,
but for Cloudflare's own JSON API rather than S3.

It handles two request-body shapes, both hand-rolled so nothing is pulled in:
a JSON body (`:json <clj-data>`) and a `multipart/form-data` upload
(`:multipart [part …]`). It is stateless and carries no per-product knowledge;
callers build paths and interpret responses.
raw docstring

clientclj

(client {:keys [api-token base-url http-client]
         :or {base-url default-base-url}})

Build a Cloudflare API client handle. :api-token is the bearer token; :base-url defaults to the public v4 endpoint. An :http-client may be supplied to share a JDK client; otherwise one is created.

Build a Cloudflare API client handle. `:api-token` is the bearer token;
`:base-url` defaults to the public v4 endpoint. An `:http-client` may be
supplied to share a JDK client; otherwise one is created.
sourceraw docstring

default-base-urlclj

source

default-http-clientclj

(default-http-client)
source

(header resp name)

First value of response header name (case-insensitive), or nil.

First value of response header `name` (case-insensitive), or nil.
sourceraw docstring

send-bytesclj

(send-bytes client req)

Like send-request, but :body in the result is the raw byte[] — for binary responses such as an image blob.

Like `send-request`, but `:body` in the result is the raw `byte[]` — for
binary responses such as an image blob.
sourceraw docstring

send-requestclj

(send-request client req)

Sign-free send of one request. req: :method "GET" | "POST" | "PATCH" | "DELETE" :path path after the base URL, e.g. "/accounts/ID/images/v1" :query map of query params (optional; URL-encoded) :headers map of extra headers (optional) :json Clojure data to send as a JSON body (optional) :multipart vector of form parts to send as multipart/form-data (optional) :body raw byte[] body (optional; ignored if :json/:multipart given)

Returns {:status int :headers {lower-name [vals]} :body <string>} for any completed exchange (including 4xx/5xx) — the body is decoded as a UTF-8 string (Cloudflare answers JSON even on errors). Network failures throw IOException.

Sign-free send of one request. `req`:
  :method     "GET" | "POST" | "PATCH" | "DELETE"
  :path       path after the base URL, e.g. "/accounts/ID/images/v1"
  :query      map of query params (optional; URL-encoded)
  :headers    map of extra headers (optional)
  :json       Clojure data to send as a JSON body (optional)
  :multipart  vector of form parts to send as multipart/form-data (optional)
  :body       raw byte[] body (optional; ignored if :json/:multipart given)

Returns `{:status int :headers {lower-name [vals]} :body <string>}` for any
completed exchange (including 4xx/5xx) — the body is decoded as a UTF-8 string
(Cloudflare answers JSON even on errors). Network failures throw IOException.
sourceraw docstring

send-streamingclj

(send-streaming client req)

Like send-request, but :body in the result is an InputStream — for downloading a large blob without buffering it. The caller must close (or fully consume) :body.

Like `send-request`, but `:body` in the result is an InputStream — for
downloading a large blob without buffering it. The caller must close (or fully
consume) `:body`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close