Toolnexus.Http (toolnexus v0.9.4)

Copy Markdown View Source

HTTP / REST tools — declare a remote endpoint as a uniform Toolnexus.Tool (SPEC §7).

Behavior mirrors the JS reference (js/src/http.ts):

  1. {placeholder}s in the URL are substituted from args (URL-encoded, consumed)
  2. args named in :query — or all remaining args on GET — become querystring params
  3. remaining args become the body (json | form | raw) on non-GET/HEAD requests

  4. ${ENV_VAR} in header values expands from the environment at call time — expanded values are never logged
  5. non-2xx ⇒ is_error with "HTTP <status>: <body>", otherwise the body text

Summary

Functions

Wrap an HTTP endpoint as a Tool.

Functions

tool(opts)

@spec tool(keyword() | map()) :: Toolnexus.Tool.t()

Wrap an HTTP endpoint as a Tool.

Options (keyword list or map):

  • :name, :description, :method, :url (required)
  • :headers — map of header name → value; values may contain ${ENV_VAR}
  • :query — list of arg names sent as querystring instead of the body
  • :body — body encoding for non-GET requests: "json" (default), "form", "raw"
  • :input_schema — JSON schema map (default: empty object schema)
  • :timeout — request timeout in ms (default 30000)
  • :result_mode"text" (default), "json", or "status+text"
  • :req_options — internal: extra Req.new/1 options (e.g. plug: for tests)