Skip to main content

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

TypeSourceDescription
APIConfigconfig.goServer configuration loaded from CRUVERO_* environment variables
Dependenciesserver.goAggregates all stores, clients, and services needed by route handlers
RouteRegistrarserver.goFunction signature for registering routes on the Huma API instance
NotFoundErrortypes/errors.goStructured 404 error with resource type and ID
ConflictErrortypes/errors.goStructured 409 conflict error
ForbiddenErrortypes/errors.goStructured 403 forbidden error
ServiceUnavailableErrortypes/errors.goStructured 503 service unavailable error
PaginationParamstypes/requests.goShared cursor-pagination query parameters
StatusResponsetypes/responses.goGeneric {"status":"ok"} response body
AsyncOperationResponsetypes/responses.goResponse for accepted async operations (workflow ID, run ID, status)

Key Files

FilePurpose
config.goAPI configuration from environment variables
server.goServer initialization, middleware chain, Huma setup
middleware/auth.goJWT (Keycloak) and API key authentication
middleware/cors.goCORS handling
middleware/logging.goZap + OTel request logging
middleware/tenant.goTenant context extraction
middleware/ratelimit.goPer-tenant rate limiting
routes/15 route files covering all API endpoints
types/Shared error types, request/response types
testutil/mocks.goMock implementations for testing