Documentation
¶
Overview ¶
Package api provides the extensible HTTP Admin API server.
Index ¶
- Constants
- func DecodeJSON(w http.ResponseWriter, r *http.Request, dst any) error
- func WriteError(w http.ResponseWriter, err error)
- type AdmissionConfig
- type Dependencies
- type MaintenanceConfig
- type ProtectedHandlerFunc
- type Server
- func (s *Server) AuditDispatcherStats() observability.AuditDispatcherStats
- func (s *Server) Handle(pattern string, handler http.Handler)
- func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
- func (s *Server) HandleModule(moduleID, pattern, permission string, handler http.Handler) (err error)
- func (s *Server) HandleProtected(pattern, permission string, handler ProtectedHandlerFunc)
- func (s *Server) Listen(addr string) error
- func (s *Server) NewHTTPServer(addr string) *http.Server
- func (s *Server) RegisterAdminProvider(provider plugin.AdminModuleProvider) error
- func (s *Server) RegisterModule(module resources.Module) error
- func (s *Server) RegisterPluginModules(registry *plugin.Registry) error
- func (s *Server) RegisterUI(provider string, descriptor adminui.Descriptor) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Shutdown(ctx context.Context) error
Constants ¶
const ( // DefaultHTTPReadHeaderTimeout bounds receipt of request headers. DefaultHTTPReadHeaderTimeout = 10 * time.Second // DefaultHTTPReadTimeout bounds receipt of headers and request bodies. Custom // HTTP servers serving Astra Admin should apply an equivalent finite limit. DefaultHTTPReadTimeout = 30 * time.Second // DefaultHTTPIdleTimeout bounds idle keep-alive connections. DefaultHTTPIdleTimeout = 60 * time.Second )
const ProtocolVersion = 1
ProtocolVersion is the server-driven admin manifest contract version.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶ added in v2.0.1
DecodeJSON decodes one bounded JSON value from a request body.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError writes a typed engine error without exposing its wrapped cause.
Types ¶
type AdmissionConfig ¶ added in v2.0.1
type AdmissionConfig struct {
ExchangeGlobalConcurrent int
ExchangePerIPConcurrent int
ExchangeGlobalRate int
ExchangePerIPRate int
ExchangeRateWindow time.Duration
ExchangeSourceBuckets int
LogStreamsGlobal int
LogStreamsPerPrincipal int
}
AdmissionConfig bounds unauthenticated session exchange work and authenticated log streams. Zero values select conservative defaults.
func (AdmissionConfig) Validate ¶ added in v2.0.1
func (c AdmissionConfig) Validate() error
type Dependencies ¶
type Dependencies struct {
App *appcore.App
EngineVersion string
Store storage.Store
Plugins *plugin.Registry
Users storage.UserRepository
Chats storage.ChatRepository
Events observability.EventLogStore
Audits observability.AuditLogStore
Metrics observability.MetricsStore
Logs *logging.Stream
Auth auth.Verifier
InsecureDevelopment bool // Grants development-only owner access when Auth is nil.
Authorization *auth.Registry
WebAuth *auth.WebAuthService
Control *admincontrol.Server
OperationRepository storage.OperationRepository
Maintenance storage.AdminMaintenance
MaintenanceConfig MaintenanceConfig
Admission AdmissionConfig
Logger *slog.Logger
}
Dependencies configures system repositories, observability and authentication.
type MaintenanceConfig ¶ added in v2.0.1
type MaintenanceConfig struct {
Disabled bool
Interval time.Duration
Timeout time.Duration
Batch int
}
MaintenanceConfig controls bounded cleanup of expired Admin credentials, sessions, tickets, and operation records. Zero values select defaults.
func (MaintenanceConfig) Validate ¶ added in v2.0.1
func (c MaintenanceConfig) Validate() error
Validate reports whether the configured non-zero limits are safe. Zero values are valid and resolve to documented defaults.
type ProtectedHandlerFunc ¶
ProtectedHandlerFunc handles an authorized request with verified claims.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves built-in system endpoints and application-defined routes.
func NewInsecureDevelopmentServer ¶ added in v2.0.2
func NewInsecureDevelopmentServer() *Server
NewInsecureDevelopmentServer creates an unauthenticated local-development server.
func NewWithDependencies ¶
func NewWithDependencies(deps Dependencies) *Server
NewWithDependencies creates a server and derives repositories from Store when set.
func NewWithPlugins ¶
NewWithPlugins creates a server backed by a plugin registry.
func (*Server) AuditDispatcherStats ¶ added in v2.0.1
func (s *Server) AuditDispatcherStats() observability.AuditDispatcherStats
AuditDispatcherStats reports bounded audit rejection, persistence failure and overload.
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc registers an application handler using net/http ServeMux patterns.
func (*Server) HandleModule ¶ added in v2.0.1
func (s *Server) HandleModule(moduleID, pattern, permission string, handler http.Handler) (err error)
HandleModule registers an authenticated handler below /admin/modules/{id}.
func (*Server) HandleProtected ¶
func (s *Server) HandleProtected(pattern, permission string, handler ProtectedHandlerFunc)
HandleProtected registers a route guarded by the configured verifier and permission.
func (*Server) NewHTTPServer ¶ added in v2.0.1
NewHTTPServer returns the bounded HTTP server configuration used by Listen. WriteTimeout is intentionally unset because Control and log streams are long-lived; upgraded Control connections own their deadlines after hijack.
func (*Server) RegisterAdminProvider ¶ added in v2.0.1
func (s *Server) RegisterAdminProvider(provider plugin.AdminModuleProvider) error
RegisterAdminProvider installs one plugin's executable Admin API hooks.
func (*Server) RegisterModule ¶ added in v2.0.1
RegisterModule adds a detached, declarative module manifest.
func (*Server) RegisterPluginModules ¶ added in v2.0.1
RegisterPluginModules installs executable admin hooks, then atomically validates and publishes all declarative UI providers. Call it once before serving; a returned error means the server must not be served. Module hooks retain their historical partial-registration behavior on error.
func (*Server) RegisterUI ¶ added in v2.0.1
func (s *Server) RegisterUI(provider string, descriptor adminui.Descriptor) error
RegisterUI validates and atomically registers a declarative UI descriptor.