HTTP

Prev Next

HTTP

The HTTP transport provides a lightweight, generic mechanism for making HTTP requests in ONECMS.

It acts as a dumb adapter around fetch, enforcing consistency while avoiding domain or business logic.

Scope and Responsibility

The HTTP transport is responsible for:

  • Executing HTTP requests
  • Applying shared request defaults
  • Providing a consistent request interface

The HTTP transport is not responsible for:

  • Business logic
  • Domain validation
  • Auth decisions
  • Retries or orchestration beyond transport-level concerns
  • UI lifecycle or routing behavior

Execution Model

  • Built on top of fetch
  • Environment-aware base URL resolution
  • Callable from both server and browser contexts where appropriate

Callers are responsible for:

  • providing request intent
  • handling domain-specific responses
  • interpreting success or failure

Headers and Context

  • Default headers may be applied at the transport level
  • Callers may override or extend headers explicitly
  • Auth headers are injected explicitly where required

No implicit reliance on:

  • global auth state
  • framework request context
  • cookies or server-only primitives

Error Handling

  • Network errors are surfaced directly
  • HTTP error responses are not silently swallowed
  • No automatic retries unless explicitly implemented at the transport level

Domain-specific error handling belongs above the transport layer.

Determinism

The HTTP transport must behave deterministically:

  • Same input → same request
  • No hidden side effects
  • No implicit mutation of caller-provided options

This makes the transport safe to use across services and modules.