Files
mygo/docs/server/decisions/0005-protocol-neutral-services.md
T

884 B

ADR-0005: Keep Service Contracts Protocol-Neutral

Status: Accepted
Date: 2026-07-05

Context

MyGO exposes REST today and is designed to support additional protocols. Business services need contracts that transport adapters can reuse.

Decision

  • Services return domain results and model.AppError values.
  • HTTP handlers own REST response DTOs.
  • internal/api maps domain error kinds to REST responses.
  • HTTP packages obtain application behavior through service contracts and authenticated principals.
  • Architecture tests enforce the package dependency boundaries.

Consequences

  • Additional protocol adapters can reuse the existing services.
  • Each protocol adapter defines its own response mapping.
  • Service tests exercise business behavior without constructing HTTP requests.
  • Error responses can include error.log_id for failures recorded by the server.