Documentation
¶
Overview ¶
Package httpapi holds the HTTP layer for both Relay planes.
- app/httpapi/inference — data plane: /v1/*, /healthz
- app/httpapi/control — admin plane: /auth/*, CRUD, /version, etc.
Each subpackage exposes a typed Deps and a Mount(chi.Router, Deps) huma.API entrypoint. The top-level package owns shared concerns: the OpenAI-shape error envelope used by both planes, the huma↔chi middleware adapter, and the build/version string.
Index ¶
Constants ¶
const Version = "0.1.0"
Version is the human-facing build version surfaced in the OpenAPI Info block and the /version endpoint. Bumped manually for now; later wired to `git describe` via -ldflags.
Variables ¶
This section is empty.
Functions ¶
func HumaAuth ¶
HumaAuth adapts a net/http middleware into a huma per-operation middleware. Used by both planes to attach auth (or any http.Handler-shaped middleware) to specific huma operations rather than the whole chi router.
Pattern: pass any `func(http.Handler) http.Handler` and it composes onto a huma.Operation via Middlewares = huma.Middlewares{HumaAuth(mw), ...}.
func Install ¶
func Install()
Install installs the process-global huma overrides: OpenAI-compatible error envelope, and a schema namer that prefixes type names with their package's last segment (e.g. provider_Spec vs host_Spec) so the catalog kinds' uniform Spec sub-structs don't collide in the OpenAPI schema registry.
Idempotent — safe to call from every Mount entrypoint.
func InstallErrorRewriter ¶
func InstallErrorRewriter()
InstallErrorRewriter is the legacy alias for Install(). Retained until callers migrate.
func NewRegistry ¶
NewRegistry returns a huma schema Registry whose namer produces clean PascalCase schema ids in the generated OpenAPI:
- The entity types Provider / Host / Model / HostKey / RateLimit / Policy / Pricing / RelayKey keep their bare names.
- Sub-types defined inside an entity package get the entity name prepended so the 8 colliding `Spec` types become `ProviderSpec`, `HostSpec`, `ModelSpec`, etc. without renaming the Go types.
- Types in non-entity packages (meta.Metadata, meta.Owner, adapter.Name, …) keep their bare names — they don't collide.
Plane Mount() functions install the returned registry on their huma.Config.
func ScalarHandler ¶
func ScalarHandler(title, specURL string) http.HandlerFunc
ScalarHandler returns an HTML page that renders the OpenAPI spec at specURL using Scalar API Reference. Use it to replace huma's default Stoplight Elements docs UI: set cfg.DocsPath = "" before humachi.New(...) and register this handler on the chi router instead.
Types ¶
type OpenAIError ¶
type OpenAIError struct {
Err OpenAIErrorInner `json:"error"`
HTTPStatus int `json:"-"`
}
OpenAIError implements huma.StatusError with the OpenAI-compatible shape:
{ "error": { "type": "...", "code": "...", "message": "..." } }
func (*OpenAIError) ContentType ¶
func (e *OpenAIError) ContentType(_ string) string
func (*OpenAIError) Error ¶
func (e *OpenAIError) Error() string
func (*OpenAIError) GetStatus ¶
func (e *OpenAIError) GetStatus() int
type OpenAIErrorInner ¶
type OpenAIErrorInner struct {
Type string `json:"type"`
Code string `json:"code,omitempty"`
Message string `json:"message"`
}
OpenAIErrorInner is the inner object of the OpenAI error envelope.
Directories
¶
| Path | Synopsis |
|---|---|
|
OIDC login for the control plane: GET /auth/oidc/start redirects to the configured provider's hosted login; GET /auth/oidc/callback exchanges the authorization code and mints the same scs session password login mints, so everything downstream of login is identical for both paths.
|
OIDC login for the control plane: GET /auth/oidc/start redirects to the configured provider's hosted login; GET /auth/oidc/callback exchanges the authorization code and mints the same scs session password login mints, so everything downstream of login is identical for both paths. |
|
Package inference's Dispatch is the shape-agnostic per-request flow.
|
Package inference's Dispatch is the shape-agnostic per-request flow. |