api

package
v0.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIAuthMiddleware added in v0.7.6

func APIAuthMiddleware(apiKey string, allowedRoles []string) func(http.Handler) http.Handler

APIAuthMiddleware authorizes requests when either the bearer token matches apiKey or when X-User-Roles contains any role listed in allowedRoles.

func APIKeyMiddleware

func APIKeyMiddleware(apiKey string) func(http.Handler) http.Handler

APIKeyMiddleware checks the Authorization header for a matching API key. Deprecated: use APIAuthMiddleware for role support.

func MiddlewareChain

func MiddlewareChain() []func(http.Handler) http.Handler

func OpenAPIHandler

func OpenAPIHandler() http.HandlerFunc

OpenAPIHandler serves the generated OpenAPI schema.

func SwaggerHandler

func SwaggerHandler() http.HandlerFunc

SwaggerHandler serves a minimal Swagger UI.

Types

type API

type API struct {
	Timeout  time.Duration
	Health   HealthChecker
	StateReg *serverstate.Registry
	generated.Unimplemented
}

func (*API) GetApiState

func (a *API) GetApiState(w http.ResponseWriter, r *http.Request)

func (*API) GetApiStateStream

func (a *API) GetApiStateStream(w http.ResponseWriter, r *http.Request)

func (*API) GetHealthz

func (a *API) GetHealthz(w http.ResponseWriter, r *http.Request)

type HealthChecker

type HealthChecker interface {
	Healthy() bool
}

type PluginsEnvelope added in v0.6.5

type PluginsEnvelope struct {
	Plugins map[string]any `json:"plugins"`
}

PluginsEnvelope is the generic, plugin-agnostic state payload.

type StateHandler

type StateHandler struct {
	// Aggregated plugin state from serverstate.Registry
	State *serverstate.Registry
}

StateHandler serves state snapshots and streams.

func (*StateHandler) GetState

func (h *StateHandler) GetState(w http.ResponseWriter, r *http.Request)

GetState returns a JSON snapshot of metrics.

func (*StateHandler) GetStateStream

func (h *StateHandler) GetStateStream(w http.ResponseWriter, r *http.Request)

GetStateStream streams state snapshots as Server-Sent Events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL