api
Production REST API layer exposing all Cruvero agent runtime functionality over HTTP. Provides OpenAPI documentation, JWT and API key authentication, per-tenant rate limiting, and structured logging with OpenTelemetry tracing.
Used by cmd/api.
Usage
import "cruvero/internal/api"
Key Types / Interfaces
| Type | Source | Description |
|---|---|---|
APIConfig | config.go | Server configuration loaded from CRUVERO_* environment variables |
Dependencies | server.go | Aggregates all stores, clients, and services needed by route handlers |
RouteRegistrar | server.go | Function signature for registering routes on the Huma API instance |
NotFoundError | types/errors.go | Structured 404 error with resource type and ID |
ConflictError | types/errors.go | Structured 409 conflict error |
ForbiddenError | types/errors.go | Structured 403 forbidden error |
ServiceUnavailableError | types/errors.go | Structured 503 service unavailable error |
PaginationParams | types/requests.go | Shared cursor-pagination query parameters |
StatusResponse | types/responses.go | Generic {"status":"ok"} response body |
AsyncOperationResponse | types/responses.go | Response for accepted async operations (workflow ID, run ID, status) |
Key Files
| File | Purpose |
|---|---|
config.go | API configuration from environment variables |
server.go | Server initialization, middleware chain, Huma setup |
middleware/auth.go | JWT (Keycloak) and API key authentication |
middleware/cors.go | CORS handling |
middleware/logging.go | Zap + OTel request logging |
middleware/tenant.go | Tenant context extraction |
middleware/ratelimit.go | Per-tenant rate limiting |
routes/ | 15 route files covering all API endpoints |
types/ | Shared error types, request/response types |
testutil/mocks.go | Mock implementations for testing |