Documentation
¶
Overview ¶
Package api exposes the HTTP approval API (and the server-rendered dashboard that sits on top of it) on the gateway's :8081 listener.
Index ¶
Constants ¶
const DefaultTemplatesDir = "web/dashboard/templates"
DefaultTemplatesDir is where the dashboard looks for its templates when none is configured, relative to the process's working directory (the repo root when running `go run ./cmd/mcp-shield` or the Docker image's WORKDIR, both of which COPY web/ alongside the binary).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailedNotificationView ¶ added in v0.1.1
type FailedNotificationView struct {
EventID int64 `json:"event_id"`
Event string `json:"event"`
Server string `json:"server"`
ManifestID int64 `json:"manifest_id"`
Attempts int `json:"attempts"`
LastError string `json:"last_error"`
CreatedAt time.Time `json:"created_at"`
}
FailedNotificationView is the shape returned by GET /api/notifications/failed: an event the dispatcher gave up on.
LastError is the target's own error text, which names the target by its configured name and never by its URL — a webhook URL is a capability-bearing credential and this endpoint is a place operators copy output from.
type ManifestView ¶
type ManifestView struct {
ID int64 `json:"id"`
Server string `json:"server"`
Hash string `json:"hash"`
State string `json:"state"`
CreatedAt time.Time `json:"created_at"`
}
ManifestView is the shape returned by GET /api/manifests/{id}.
type Option ¶ added in v0.1.1
type Option func(*Server)
Option adjusts optional server behaviour.
func WithFailedNotifications ¶ added in v0.1.1
WithFailedNotifications enables GET /api/notifications/failed, reporting events that reached maxAttempts without being delivered. Without it the route 404s: an operator who configured no targets should be told the surface does not exist, rather than shown an empty list that reads as "everything was delivered".
type PendingManifestView ¶
type PendingManifestView struct {
ID int64 `json:"id"`
Server string `json:"server"`
Hash string `json:"hash"`
Changes []string `json:"changes"`
CreatedAt time.Time `json:"created_at"`
}
PendingManifestView is the shape returned by GET /api/manifests/pending.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(store database.Store, workflow *approval.Workflow, templatesDir string, opts ...Option) *Server
NewServer builds the API+dashboard handler. templatesDir may be empty, in which case DefaultTemplatesDir is used; if templates fail to parse the JSON API still works, only the HTML dashboard routes degrade.