controllers

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIncident

func CreateIncident(c *fiber.Ctx) error

func HandleAck

func HandleAck(c *fiber.Ctx) error

func HealthCheck

func HealthCheck(c *fiber.Ctx) error

func MountStaticUI added in v1.3.9

func MountStaticUI(app *fiber.App)

MountStaticUI registers the embedded UI at "/" with SPA fallback so client-side routes like /dashboard, /incidents/:id, /shadow/:id all resolve to index.html when the asset doesn't exist.

Call this AFTER all API/admin routes are registered; otherwise the catch-all would shadow them.

func SNS

func SNS(c *fiber.Ctx) error

Types

type AgentController added in v1.3.9

type AgentController struct {
	// contains filtered or unexported fields
}

AgentController exposes admin endpoints for inspecting and curating the pattern catalog. All endpoints require the gateway secret configured under `agent.gateway_secret` (or env AGENT_GATEWAY_SECRET), sent in the `X-Gateway-Secret` header. When no secret is configured, every request is rejected — this is by design: an empty secret must not silently grant access.

func NewAgentController added in v1.3.9

func NewAgentController(cat *agent.Catalog, sl *agent.ShadowLog, dl *agent.DetectLog) *AgentController

NewAgentController wires the catalog, shadow log, and detect log into a controller. Pass `cat=nil` if the agent is disabled — in that case every endpoint will return 503. `sl` may be nil to disable the shadow endpoints, and `dl` may be nil to disable the detect-log endpoints.

func (*AgentController) Register added in v1.3.9

func (a *AgentController) Register(router fiber.Router)

Register attaches the agent admin endpoints to the given fiber group.

Routes (under /api/agent):

GET    /patterns         list all patterns (sorted by Count desc)
GET    /patterns/:id     get one pattern
POST   /patterns/:id     update verdict / tags
DELETE /patterns/:id     remove a pattern
POST   /flush            force-flush the catalog to disk
GET    /status           lightweight status (catalog size, dirty flag)
GET    /shadow           list shadow-mode "would have alerted" events
GET    /shadow/stats     aggregate counts for the shadow log
DELETE /shadow           clear the shadow log
POST   /shadow/flush     force-flush the shadow log to disk
GET    /services         list known services with grace status
POST   /services/:name/grace  control grace period (end / restart)
GET    /detect           list detect-mode AI calls (newest first)
GET    /detect/stats     aggregate counts for the detect log
GET    /detect/:id       get one detect-mode AI call (full prompt + response)
DELETE /detect           clear the detect log
POST   /detect/flush     force-flush the detect log to disk
GET    /ai/system-prompt the assembled system prompt sent on every AI call

type ConfigAdminController added in v1.3.9

type ConfigAdminController struct{}

ConfigAdminController exposes a read-only, secret-redacted view of the running config so the admin dashboard can render it without ever exposing tokens, passwords, or webhook URLs. Same gateway-secret guard as the rest of the admin surface.

func NewConfigAdminController added in v1.3.9

func NewConfigAdminController() *ConfigAdminController

func (*ConfigAdminController) Register added in v1.3.9

func (c *ConfigAdminController) Register(router fiber.Router)

Register attaches:

GET /api/admin/config/incidents   alert channels + queue + on-call
GET /api/admin/config/agent       agent runtime config

type IncidentAdminController added in v1.3.9

type IncidentAdminController struct{}

IncidentAdminController exposes read endpoints for the persisted incident history. Same X-Gateway-Secret guard as the agent admin surface — see AgentController.authMiddleware.

func NewIncidentAdminController added in v1.3.9

func NewIncidentAdminController() *IncidentAdminController

NewIncidentAdminController returns a controller. No state of its own; the storage provider is read lazily via services.Storage().

func (*IncidentAdminController) Register added in v1.3.9

func (i *IncidentAdminController) Register(router fiber.Router)

Register attaches the admin endpoints under /api/admin/incidents.

GET  /api/admin/incidents              list (newest first; ?limit=NN)
GET  /api/admin/incidents/:id          single record
POST /api/admin/incidents/:id/resolve  mark resolved (idempotent)

type SNSMessage

type SNSMessage struct {
	Type             string `json:"Type"`
	MessageId        string `json:"MessageId"`
	Token            string `json:"Token,omitempty"` // Omit empty for Notification type
	TopicArn         string `json:"TopicArn"`
	Message          string `json:"Message"`
	SubscribeURL     string `json:"SubscribeURL,omitempty"` // Omit empty for Notification type
	Timestamp        string `json:"Timestamp"`
	SignatureVersion string `json:"SignatureVersion"`
	Signature        string `json:"Signature"`
	SigningCertURL   string `json:"SigningCertURL"`
}

type TeamsAdminController added in v1.4.1

type TeamsAdminController struct {
	// contains filtered or unexported fields
}

TeamsAdminController exposes CRUD for members and teams plus an incident-assignment endpoint. Same X-Gateway-Secret guard as the other /api/admin/* controllers.

func NewTeamsAdminController added in v1.4.1

func NewTeamsAdminController(s *teams.Store) *TeamsAdminController

NewTeamsAdminController returns a controller backed by the given teams store. Pass nil to disable the endpoints entirely (every request returns 503).

func (*TeamsAdminController) Register added in v1.4.1

func (c *TeamsAdminController) Register(router fiber.Router)

Register mounts the admin routes:

GET    /api/admin/members              list
POST   /api/admin/members              create
GET    /api/admin/members/:id          get one
PATCH  /api/admin/members/:id          partial update
DELETE /api/admin/members/:id          delete (+ scrub team refs)

GET    /api/admin/teams                list
POST   /api/admin/teams                create
GET    /api/admin/teams/:id            get one
PATCH  /api/admin/teams/:id            partial update
DELETE /api/admin/teams/:id            delete

POST   /api/admin/incidents/:id/assign assign team + members

Jump to

Keyboard shortcuts

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