Skip to main content

Module api

Module api 

Source
Expand description

API block — HTTP request via reqwest. Honors {{...}} interpolation in url, headers, and body.

Config (node.data):

  • method — “GET” / “POST” / “PUT” / “DELETE” / “PATCH” (default GET)
  • url — required; supports {{...}}
  • headers — optional { name: value } map; values support {{...}}
  • body — optional string body (POST/PUT/PATCH); supports {{...}}
  • auth — optional { vault: "<entry>", as: "bearer" | "header:<Name>" }: a Vault entry’s value sent as that header. See super::api_auth for what keeps it on the one site the drone names; the first call asks the person.

Output:

{ "status": 200, "body": <parsed-json-or-text>, "headers": { ... } }

A response is read up to MAX_RESPONSE_BYTES; a longer one is an error.

Structs§

Credential 🔒
What a call with a Vault credential sends it as, and what takes it out of the answer.

Constants§

DEFAULT_TIMEOUT_MS 🔒
MAX_RESPONSE_BYTES 🔒
The most of a response a call reads: a drone’s ledger is not where a download goes.

Statics§

CREDENTIAL_CLIENT 🔒
The client for a call with a Vault credential: it follows no redirect, so the credential goes to the one site the drone names and nowhere a response points.
HTTP_CLIENT 🔒
Shared reqwest::Client so drones with multiple API blocks reuse one connection pool instead of building a new pool per request. Per-request timeouts move to the RequestBuilder. (reagent P2 on PR #755.)

Functions§

clean 🔒
text with the credential taken out of it, when the call had one.
credential 🔒
Checks and resolves the node’s auth, asking the person the first time. None when the node has none. Nothing is sent, and nothing but the person’s answer is waited for.
credential_client 🔒
exchange 🔒
Send the request and read the whole answer. A timeout says nothing about whether the other side did the work, so it is worded apart from a failure to connect: the retry policy runs the second again and never the first.
http_client 🔒
is_reserved_v4 🔒
is_reserved_v6 🔒
read_capped 🔒
The response’s body up to MAX_RESPONSE_BYTES.
read_error 🔒
A failure while reading the body: a timeout is worded apart from the rest (see exchange).
run
validate_url_for_safety 🔒
Same checks as validate_url_safety but takes a pre-parsed reqwest::Url. The redirect-policy closure receives Url values directly, so this avoids a parse round-trip on every hop.
validate_url_safety 🔒
Validate a resolved URL before dispatching it. Phase 1 SSRF protection: rejects non-http(s) schemes and literal-IP hosts that fall into reserved / link-local / private / loopback ranges (the AWS metadata endpoint 169.254.169.254, RFC1918 space, 127.0.0.1, fc00::/7, ::1, etc.). DNS-resolved hostnames are not re-checked post-resolution — that requires a custom reqwest resolver and lands as a follow-up issue. See kimi P1 on PR #755.