Skip to main content

Module http

Module http 

Source
Expand description

Low-level REST transport for the opencode server.

This module owns three concerns shared by every hand-wrapped endpoint:

  • Base-URL handling — a normalized origin (trailing slashes stripped) against which typed path builders produce absolute request URLs.
  • HTTP Basic auth — opencode requires Basic auth only when the server was started with a password (username defaults to "opencode"). Credentials are supplied explicitly; the OPENCODE_SERVER_PASSWORD environment variable is read only through BasicAuth::from_env, never silently on a request path.
  • A typed request helperHttpTransport::request_json / HttpTransport::request_unit send a JSON body (if any), apply auth and the optional per-request timeout, and map any non-2xx status to Error::Http carrying the server’s response body.

Path parameters ({sessionID}, {permissionID}) are percent-encoded against the RFC 3986 unreserved set before being placed into the path.

Structs§

BasicAuth
HTTP Basic credentials for the opencode server.
HttpTransport
Low-level JSON-over-HTTP transport bound to one opencode base URL.
Scope
Directory / workspace scoping for the session endpoints.

Constants§

DEFAULT_USERNAME
Default HTTP Basic auth username opencode expects when a server password is configured.
SERVER_PASSWORD_ENV
Environment variable opencode reads for its server password. Used only by BasicAuth::from_env.