Skip to content

Add high-level HTTP method helpers to zigttp:fetch#21

Draft
srdjan wants to merge 2 commits into
mainfrom
codex/update-http-client-module-with-new-approach
Draft

Add high-level HTTP method helpers to zigttp:fetch#21
srdjan wants to merge 2 commits into
mainfrom
codex/update-http-client-module-with-new-approach

Conversation

@srdjan
Copy link
Copy Markdown
Owner

@srdjan srdjan commented Apr 29, 2026

Motivation

  • Improve handler ergonomics by exposing high-level HTTP method helpers so Zig-specific request boilerplate is not required in zigts handlers.
  • Keep virtual-module contracts, egress-host extraction, and runtime delegation intact so verification and policy tooling continue to work.

Description

  • Added get, post, put, patch, and delete exports to zigttp:fetch with the same effect/contract_extractions metadata as fetch so proof and egress extraction remain correct (file: packages/modules/src/net/fetch.zig).
  • Implemented fetchWithMethod which validates args, forces the HTTP method, and delegates to the existing runtime callback path (state.call_fn) so runtime behavior is unchanged.
  • Implemented cloneWithMethod which copies an init object via sdk.objectKeys/sdk.objectGet and sets the method field, preserving other RequestInit fields for the helpers.
  • Updated documentation to advertise the new helpers and describe that they clone init and set method automatically (file: docs/virtual-modules/net/fetch.md).

Testing

  • Attempted to run formatting and the Zig test suite with zig fmt packages/modules/src/net/fetch.zig and zig build test-zigts, but the environment lacks Zig so both commands failed with zig: command not found and automated tests could not be executed.
  • No new Zig test blocks were added in this change; the change is limited to packages/modules/src/net/fetch.zig and the corresponding docs update.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant