Documentation
¶
Overview ¶
Package http provides HTTP handlers that delegate to application services.
Index ¶
- func NewRouter(cfg RouterConfig) *http.ServeMux
- type AuthMiddleware
- type Handlers
- func (h *Handlers) Activate(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminDeleteInstance(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminGetApplication(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminInstances(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminListApplications(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminMetrics(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminRefreshStars(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminStats(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) AdminUpdateApplication(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) BadgeCombined(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) BadgeInstances(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) BadgeMetric(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) BadgeVersion(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) Healthcheck(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) Register(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) Snapshot(w http.ResponseWriter, r *http.Request)
- type KeyProvider
- type RegisterRequest
- type RouterConfig
- type SnapshotRequest
- type UpdateApplicationRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRouter ¶
func NewRouter(cfg RouterConfig) *http.ServeMux
NewRouter creates a fully wired HTTP router with all handlers and middleware.
Types ¶
type AuthMiddleware ¶
type AuthMiddleware struct {
// contains filtered or unexported fields
}
AuthMiddleware provides Ed25519 signature verification for requests.
func NewAuthMiddleware ¶
func NewAuthMiddleware(keys KeyProvider, logger *slog.Logger) *AuthMiddleware
NewAuthMiddleware creates a new AuthMiddleware.
func NewAuthMiddlewareFromService ¶
func NewAuthMiddlewareFromService(svc *app.InstanceService, logger *slog.Logger) *AuthMiddleware
NewAuthMiddlewareFromService creates an AuthMiddleware using an InstanceService.
func (*AuthMiddleware) RequireSignature ¶
func (m *AuthMiddleware) RequireSignature(next http.HandlerFunc) http.HandlerFunc
RequireSignature wraps a handler to require a valid Ed25519 signature. The request must have X-Instance-ID and X-Signature headers. The signature is verified against the request body using the instance's public key.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers holds HTTP handlers and their dependencies.
func NewHandlers ¶
func NewHandlers( instances *app.InstanceService, snapshots *app.SnapshotService, applications *app.ApplicationService, dashboard *app.DashboardService, logger *slog.Logger, ) *Handlers
NewHandlers creates a new Handlers with the given services.
func (*Handlers) Activate ¶
func (h *Handlers) Activate(w http.ResponseWriter, r *http.Request)
Activate handles instance activation requests.
func (*Handlers) AdminDeleteInstance ¶ added in v1.2.2
func (h *Handlers) AdminDeleteInstance(w http.ResponseWriter, r *http.Request)
AdminDeleteInstance handles instance deletion requests.
func (*Handlers) AdminGetApplication ¶ added in v1.2.0
func (h *Handlers) AdminGetApplication(w http.ResponseWriter, r *http.Request)
AdminGetApplication handles getting a single application by slug.
func (*Handlers) AdminInstances ¶
func (h *Handlers) AdminInstances(w http.ResponseWriter, r *http.Request)
AdminInstances handles instance listing requests.
func (*Handlers) AdminListApplications ¶ added in v1.2.0
func (h *Handlers) AdminListApplications(w http.ResponseWriter, r *http.Request)
AdminListApplications handles listing all applications.
func (*Handlers) AdminMetrics ¶
func (h *Handlers) AdminMetrics(w http.ResponseWriter, r *http.Request)
AdminMetrics handles metrics time-series requests.
func (*Handlers) AdminRefreshStars ¶ added in v1.2.0
func (h *Handlers) AdminRefreshStars(w http.ResponseWriter, r *http.Request)
AdminRefreshStars handles manual GitHub stars refresh for a specific application.
func (*Handlers) AdminStats ¶
func (h *Handlers) AdminStats(w http.ResponseWriter, r *http.Request)
AdminStats handles dashboard statistics requests.
func (*Handlers) AdminUpdateApplication ¶ added in v1.2.0
func (h *Handlers) AdminUpdateApplication(w http.ResponseWriter, r *http.Request)
AdminUpdateApplication handles updating an application's metadata.
func (*Handlers) BadgeCombined ¶ added in v1.2.0
func (h *Handlers) BadgeCombined(w http.ResponseWriter, r *http.Request)
func (*Handlers) BadgeInstances ¶ added in v1.2.0
func (h *Handlers) BadgeInstances(w http.ResponseWriter, r *http.Request)
func (*Handlers) BadgeMetric ¶ added in v1.2.0
func (h *Handlers) BadgeMetric(w http.ResponseWriter, r *http.Request)
func (*Handlers) BadgeVersion ¶ added in v1.2.0
func (h *Handlers) BadgeVersion(w http.ResponseWriter, r *http.Request)
func (*Handlers) Healthcheck ¶
func (h *Handlers) Healthcheck(w http.ResponseWriter, r *http.Request)
Healthcheck returns a simple health status.
type KeyProvider ¶
KeyProvider is an interface for retrieving public keys for signature verification.
type RegisterRequest ¶
type RegisterRequest struct {
InstanceID string `json:"instance_id"`
PublicKey string `json:"public_key"`
AppName string `json:"app_name"`
AppVersion string `json:"app_version"`
DeploymentMode string `json:"deployment_mode"`
Environment string `json:"environment"`
OSArch string `json:"os_arch"`
}
RegisterRequest is the JSON payload for instance registration.
type RouterConfig ¶
type RouterConfig struct {
Store *postgres.Store
RateLimiter *middleware.RateLimiter
GitHubToken string // Optional GitHub API token for higher rate limits
Logger *slog.Logger
}
RouterConfig holds the configuration for creating a new router.
type SnapshotRequest ¶
type SnapshotRequest struct {
InstanceID string `json:"instance_id"`
Timestamp time.Time `json:"timestamp"`
Metrics json.RawMessage `json:"metrics"`
}
SnapshotRequest is the JSON payload for snapshot submission.
type UpdateApplicationRequest ¶ added in v1.2.0
type UpdateApplicationRequest struct {
GitHubURL string `json:"github_url"`
LogoURL string `json:"logo_url"`
}
UpdateApplicationRequest is the JSON payload for updating an application.