Documentation
¶
Overview ¶
Package apihttp holds HTTP helpers shared by every version of the public API (pkg/api/v1, pkg/api/v2, ...). It is intentionally a leaf package with no dependencies on pkg/api so version subpackages can import it without creating an import cycle through the top-level router.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, status int, message string)
WriteError writes an error envelope using models.ErrorResponse so all API versions return errors in the same shape.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, status int, value any)
WriteJSON serializes value as JSON and writes it with the given status.
func WriteStoreAwareError ¶
func WriteStoreAwareError(logger *slog.Logger, w http.ResponseWriter, err error)
WriteStoreAwareError maps the small set of well-known service-layer error kinds to HTTP responses. The mapping (404 for missing sandboxes, 503 + Retry-After for capacity, 400 for everything else) is a contract clients depend on regardless of API version, so it lives here in the shared helper package.
Types ¶
This section is empty.