Skip to content

http adapter: REST path params + PATCH/PUT/DELETE + broker pattern allow-list#39

Merged
TeoSlayer merged 4 commits into
pilot-protocol:mainfrom
Alexgodoroja:agentphone-https-adapter
Jun 25, 2026
Merged

http adapter: REST path params + PATCH/PUT/DELETE + broker pattern allow-list#39
TeoSlayer merged 4 commits into
pilot-protocol:mainfrom
Alexgodoroja:agentphone-https-adapter

Conversation

@Alexgodoroja

Copy link
Copy Markdown
Collaborator

The HTTP adapter rails supported only GET/POST on static paths, and the broker allow-list was exact-match. That can't express a REST API with path params (e.g. AgentPhone's GET /v1/calls/{id} for call-status/transcript polling — the non-websocket way to learn a call outcome) or PATCH/DELETE resources. This adds them, with tests.

Generator (internal/scaffold)

  • http.verb accepts GET|POST|PATCH|PUT|DELETE (was GET|POST).
  • http.path supports {name} placeholders; Resolve derives PathParams, Validate requires each {name} to have a matching params: entry.
  • One generic forward(): fills {name} from the payload (URL-escaped, dropped from body/query), then sends remaining fields as a JSON body (POST/PATCH/PUT) or query string (GET/DELETE), preserving nested JSON in bodies. Adds a generic client.Do().

Broker (internal/broker, internal/publish)

  • Allow-list entries with a {seg} match any single non-empty path segment, so REST path params don't each need enumerating; exact entries still fast-path. The forward path already used r.Method, so PATCH/DELETE needed no change.
  • BrokerEntry derives the auth scheme (e.g. Bearer) from a managed submission header value, so a Bearer partner is injected as Authorization: Bearer <key>.

Tests (full suite green): verb accept/reject, path-param derivation + must-be-declared, broker pattern matching (incl. empty-deny), Bearer-scheme derivation, and a managed-HTTP generate→compile covering all five verbs + path params. Example spec documents the feature.

Alex Godoroja and others added 4 commits June 24, 2026 13:16
…low-list

The HTTP adapter rails only supported GET/POST on static paths, and the broker
allow-list was exact-match. That can't express a REST API with path params
(e.g. AgentPhone's GET /v1/calls/{id} for call-status/transcript polling, the
non-websocket way to learn a call outcome) or PATCH/DELETE resources.

Generator (internal/scaffold):
- http.verb now accepts GET|POST|PATCH|PUT|DELETE (was GET|POST).
- http.path supports {name} placeholders; Resolve derives PathParams, Validate
  requires each {name} to have a matching params: entry.
- one generic forward(): fills {name} from the payload (URL-escaped, dropped from
  body/query), sends remaining fields as JSON body (POST/PATCH/PUT) or query
  (GET/DELETE), preserving nested JSON in bodies. Adds a generic client.Do().

Broker (internal/broker):
- allow-list entries with a {seg} match any single non-empty path segment, so
  REST path params don't each need enumerating; exact entries still fast-path.
  The forward path already used r.Method, so PATCH/DELETE needed no change.

Tests: verb acceptance/rejection, path-param derivation + must-be-declared,
broker pattern matching (incl. empty-deny), and a managed-HTTP generate+compile
covering all five verbs + path params. Example spec documents the feature.
BrokerEntry captured the auth header name but dropped the scheme, so a Bearer
partner (e.g. AgentPhone: Authorization: Bearer <key>) was injected as a bare
Authorization: <key>. Parse a scheme prefix from the header value ("Bearer
managed" -> scheme "Bearer"; bare "managed" -> no scheme, e.g. x-api-key).
Test covers Bearer derivation + templated allow-path passthrough.
@TeoSlayer TeoSlayer merged commit b3b4c97 into pilot-protocol:main Jun 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants