Documentation
¶
Overview ¶
Package stdhttp registers bundled frontend HTTP handlers on a ServeMux (standard distribution wiring).
Package stdhttp provides HTTP server wiring; recovery middleware isolates request panics.
Index ¶
- Constants
- Variables
- func ComposeStandardHTTP(ctx context.Context, cfg *config.Config, log *slog.Logger, ...) (http.Handler, error)
- func DefaultRouteSelector(cfg *config.Config) string
- func DownstreamServerMiddleware(cfg *config.Config, next http.Handler) http.Handler
- func MountBundledFrontends(in MountBundledFrontendsInput) error
- func NewCatalogStatusHandler(log *slog.Logger, cfg modelcatalog.CatalogStatusHandlerConfig) http.Handler
- func RecoveryMiddleware(log *slog.Logger, next http.Handler) http.Handler
- func RunWithGenerationHost(ctx context.Context, in GenerationHostInput) error
- type CredentialDisposition
- type CredentialProbe
- type GenerationHostInput
- type GenerationServeHost
- type GeoIPResolverConfig
- type GeoIPSecurityInput
- type HTTPCoreInput
- type HTTPFrontendInput
- type HTTPModelInput
- type HTTPOperationsInput
- type HTTPSecurityInput
- type ModelRegistryHandler
- type ModelRegistryStatusHandler
- type MountBundledFrontendsInput
- type SelfDefenseObserver
- type SelfDefenseSecurityInput
- type StandardHTTPInput
- type TerminalDecisionPolicyInput
Constants ¶
const ( // MayAuthenticate and DefinitelyNoCredential are the closed answers of the // conservative credential-presence probe, re-exported so the standard // composition and its tests share one vocabulary with the contract. MayAuthenticate = httpcontract.MayAuthenticate DefinitelyNoCredential = httpcontract.DefinitelyNoCredential )
Variables ¶
var ErrRouteConflict = errors.New("stdhttp: route conflict")
ErrRouteConflict is returned when request-plane route registration collides (frontend/diagnostics/models mounts) during generation composition.
Functions ¶
func ComposeStandardHTTP ¶
func DefaultRouteSelector ¶
DefaultRouteSelector returns the routing selector used by frontends when X-LIP-Route is absent. It delegates to config.EffectiveDefaultRouteSelector with standardplugins.DefaultWireModel so default models are registry-owned, not duplicated in frontend handlers.
Prefer using runtimebundle.CandidateHTTPCompile.EffectiveDefaultRoute so HTTP wiring shares the same wire-model selection as the executor (including optional runtimebundle.BuildOptions.WireModel).
func DownstreamServerMiddleware ¶
DownstreamServerMiddleware presents proxy identity to A-leg HTTP clients via the standard Server response header. It wraps ResponseWriter with a thin policy writer that re-applies proxy|custom|drop immediately before every WriteHeader, implicit Write, and Flush so inner handlers cannot leak a conflicting Server after commit.
The wrapper preserves http.Flusher (required by streaming frontend encoders), Unwrap() for http.ResponseController, and optional Hijacker/Pusher/ReaderFrom forwarding matching internal/core/http.ResponseStatusRecorder.
Scope: standard HTTP stack-wide (outermost around [stackHTTPHandler]) so auth denials, frontend protocol errors, recovery 500s, not-found, diagnostics, and successful frontend responses share the same Server identity.
func MountBundledFrontends ¶
func MountBundledFrontends(in MountBundledFrontendsInput) error
MountBundledFrontends registers enabled frontend protocol handlers from config on mux. Gemini is mounted under /v1beta/ and /v1beta1/ only (after other prefixes when present). MaxRequestBodyBytes is forwarded to handlers; zero means each handler's default body cap. Mux, Frontends.Executor, and Frontends.Registry must be non-nil.
func NewCatalogStatusHandler ¶
func NewCatalogStatusHandler(log *slog.Logger, cfg modelcatalog.CatalogStatusHandlerConfig) http.Handler
NewCatalogStatusHandler serves GET JSON from modelcatalog.BuildCatalogDiagnosticsJSON for the request time. log is the process HTTP logger (same as [Run]); if nil, slog.Default is used. When the request carries a bound catalog view, diagnostics use that snapshot rather than rereading the live runtime (req 9.6).
func RecoveryMiddleware ¶
RecoveryMiddleware recovers panics from inner handlers, maps them to safety.PanicError, and returns a safe 500 when the response is not yet committed. After http.ResponseWriter headers are committed, it logs only and does not write a second error body.
func RunWithGenerationHost ¶
func RunWithGenerationHost(ctx context.Context, in GenerationHostInput) error
RunWithGenerationHost serves one long-lived http.Server backed by the host-provided stable generation dispatcher. Startup listener/timeouts are fixed from Config. This adapter owns only the http.Server; shutdown is:
- reject reload triggers (host.BeginShutdown)
- stop and drain HTTP, then await the serve worker
- close the optional management listener
- invoke host.Close exactly once for that shutdown attempt
If the HTTP drain fails or times out, host.Close is not invoked so live handlers are never closed underneath. Management and host errors are joined with any serve error and returned truthfully.
Types ¶
type CredentialDisposition ¶
type CredentialDisposition = httpcontract.CredentialDisposition
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type CredentialProbe ¶
type CredentialProbe = httpcontract.CredentialProbe
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type GenerationHostInput ¶
type GenerationHostInput struct {
Config *config.Config
Log *slog.Logger
// Host owns every generation/process/tracing shutdown decision.
Host GenerationServeHost
// Management is the optional process-owned management listener, closed in
// its established position after the data plane drains and before the
// host-owned teardown (task 5.6).
Management interface {
Shutdown(context.Context) error
}
// ShutdownTimeout bounds the HTTP drain and the host close. Zero uses
// [config.ServerConfig.EffectiveShutdownTimeout] (15s when omitted).
ShutdownTimeout time.Duration
}
GenerationHostInput configures RunWithGenerationHost.
type GenerationServeHost ¶
type GenerationServeHost interface {
// HTTPHandler returns the process-stable request dispatcher.
HTTPHandler() http.Handler
// BeginShutdown rejects new reload triggers before the HTTP drain starts.
BeginShutdown()
// Close runs the host-owned shutdown ordering after the HTTP drain.
Close(context.Context) error
}
GenerationServeHost is the focused host-facing seam this adapter needs (req 8.6-8.7). It exposes the stable data-plane handler, early reload-trigger rejection, and the canonical process shutdown coordinator — never the generation manager, process runtime, or tracing primitives behind them.
type GeoIPResolverConfig ¶
type GeoIPResolverConfig = httpcontract.GeoIPResolverConfig
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type GeoIPSecurityInput ¶
type GeoIPSecurityInput = httpcontract.GeoIPSecurityInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type HTTPCoreInput ¶
type HTTPCoreInput = httpcontract.HTTPCoreInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type HTTPFrontendInput ¶
type HTTPFrontendInput = httpcontract.HTTPFrontendInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type HTTPModelInput ¶
type HTTPModelInput = httpcontract.HTTPModelInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type HTTPOperationsInput ¶
type HTTPOperationsInput = httpcontract.HTTPOperationsInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type HTTPSecurityInput ¶
type HTTPSecurityInput = httpcontract.HTTPSecurityInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type ModelRegistryHandler ¶
type ModelRegistryHandler struct {
// contains filtered or unexported fields
}
ModelRegistryHandler serves OpenAI-compatible GET /v1/models. When the request carries a bound registry view (generation-dispatched), that immutable view is used. Otherwise the live runtime is read for compatibility with legacy/direct constructors.
func NewModelRegistryHandler ¶
func NewModelRegistryHandler(rt *modelregistry.Runtime) *ModelRegistryHandler
NewModelRegistryHandler returns a concrete handler for GET /v1/models.
func (*ModelRegistryHandler) ServeHTTP ¶
func (h *ModelRegistryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ModelRegistryStatusHandler ¶
type ModelRegistryStatusHandler struct {
// contains filtered or unexported fields
}
ModelRegistryStatusHandler serves protected GET JSON for model-registry discovery diagnostics. Prefer the request-bound registry view when present; otherwise read the live runtime (legacy/direct constructors).
func NewModelRegistryStatusHandler ¶
func NewModelRegistryStatusHandler(rt *modelregistry.Runtime) *ModelRegistryStatusHandler
NewModelRegistryStatusHandler returns a concrete diagnostics status handler.
func (*ModelRegistryStatusHandler) ServeHTTP ¶
func (h *ModelRegistryStatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MountBundledFrontendsInput ¶
type MountBundledFrontendsInput struct {
Mux *http.ServeMux
Frontends HTTPFrontendInput
}
MountBundledFrontendsInput carries the generic frontend composition inputs.
type SelfDefenseObserver ¶
type SelfDefenseObserver = httpcontract.SelfDefenseObserver
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type SelfDefenseSecurityInput ¶
type SelfDefenseSecurityInput = httpcontract.SelfDefenseSecurityInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type StandardHTTPInput ¶
type StandardHTTPInput = httpcontract.StandardHTTPInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
type TerminalDecisionPolicyInput ¶
type TerminalDecisionPolicyInput = httpcontract.TerminalDecisionPolicyInput
StandardHTTPInput and its groups are exact aliases of the cycle-neutral internal/stdhttp/contract definitions (task 3.4).
Source Files
¶
- accesslog.go
- admin_unix.go
- cancel.go
- catalog_status_handler.go
- diagprotect.go
- generation_host.go
- handler.go
- middleware.go
- model_registry_handler.go
- model_registry_status_handler.go
- mount.go
- mount_admin.go
- mount_diagnostics.go
- mount_metrics.go
- mount_securesession.go
- openai_models_list.go
- recovery.go
- request_plane.go
- route.go
- route_conflict.go
- security_guard.go
- server.go
- server_identity.go
- terminal_decision_policy_mount.go
Directories
¶
| Path | Synopsis |
|---|---|
|
admin
|
|
|
configreload
Package configreload implements the process-owned management HTTP adapter for explicit configuration reload and status (spec versioned-runtime-reloadable-proxy-configuration task 5.3; requirements 1.3, 1.7, 12.1-12.11, 13.1-13.2).
|
Package configreload implements the process-owned management HTTP adapter for explicit configuration reload and status (spec versioned-runtime-reloadable-proxy-configuration task 5.3; requirements 1.3, 1.7, 12.1-12.11, 13.1-13.2). |
|
controlplane
Package controlplane mounts the protected operator status and query HTTP surface for the control-plane persistence/query/event-ledger capability (spec control-plane-persistence-query-event-ledger; tasks 5.3, 5.4).
|
Package controlplane mounts the protected operator status and query HTTP surface for the control-plane persistence/query/event-ledger capability (spec control-plane-persistence-query-event-ledger; tasks 5.3, 5.4). |
|
Package auth integrates transport-layer httpauth.Provider chains into stdhttp.
|
Package auth integrates transport-layer httpauth.Provider chains into stdhttp. |
|
Package contract defines the cycle-neutral HTTP composition input value types shared by runtimebundle (canonical construction) and stdhttp (canonical and transitional composition).
|
Package contract defines the cycle-neutral HTTP composition input value types shared by runtimebundle (canonical construction) and stdhttp (canonical and transitional composition). |
|
Package selfdefense is the standard-HTTP driving adapter for ingress self-defense.
|
Package selfdefense is the standard-HTTP driving adapter for ingress self-defense. |
|
Package terminalpolicy provides the provider-neutral HTTP adapter for the process-owned terminal-decision policy.
|
Package terminalpolicy provides the provider-neutral HTTP adapter for the process-owned terminal-decision policy. |