Documentation
¶
Index ¶
- Constants
- Variables
- func Healthz(w http.ResponseWriter, r *http.Request)
- func NewRouter(manager *uptime.Manager, store *db.Store, cfg *config.Config) http.Handler
- func RateLimitMiddleware(limiter *IPRateLimiter) func(http.Handler) http.Handler
- func Readyz(store *db.Store) http.HandlerFunc
- func SecureHeadersWithConfig(cookieSecure bool) func(http.Handler) http.Handler
- func SecurityHeaders(next http.Handler) http.Handler
- type APIKeyHandler
- type AdminHandler
- type AuthHandler
- func (h *AuthHandler) AuthMiddleware(next http.Handler) http.Handler
- func (h *AuthHandler) IsAuthenticated(r *http.Request) bool
- func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request)
- func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)
- func (h *AuthHandler) Me(w http.ResponseWriter, r *http.Request)
- func (h *AuthHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
- type CRUDHandler
- func (h *CRUDHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) CreateMonitor(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) DeleteGroup(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) DeleteMonitor(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) GetGroups(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) PauseMonitor(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) ResumeMonitor(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) UpdateGroup(w http.ResponseWriter, r *http.Request)
- func (h *CRUDHandler) UpdateMonitor(w http.ResponseWriter, r *http.Request)
- type EventHandler
- type GroupDTO
- type GroupOverviewDTO
- type HistoryPoint
- type IPRateLimiter
- type IncidentDTO
- type IncidentHandler
- func (h *IncidentHandler) AddUpdate(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) CreateIncident(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) DeleteIncident(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) GetIncident(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) GetIncidents(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) GetUpdates(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) PromoteOutage(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) SetVisibility(w http.ResponseWriter, r *http.Request)
- func (h *IncidentHandler) UpdateIncident(w http.ResponseWriter, r *http.Request)
- type IncidentResponseDTO
- type LoginRateLimiter
- func (l *LoginRateLimiter) Allow(ip string) bool
- func (l *LoginRateLimiter) AllowUsername(username string) bool
- func (l *LoginRateLimiter) BlockDuration(ip string) time.Duration
- func (l *LoginRateLimiter) RecordFailure(ip string)
- func (l *LoginRateLimiter) RecordSuccess(ip string)
- func (l *LoginRateLimiter) RecordUsernameFailure(username string)
- func (l *LoginRateLimiter) RecordUsernameSuccess(username string)
- func (l *LoginRateLimiter) UsernameBlockDuration(username string) time.Duration
- type LoginRequest
- type MaintenanceHandler
- func (h *MaintenanceHandler) CreateMaintenance(w http.ResponseWriter, r *http.Request)
- func (h *MaintenanceHandler) DeleteMaintenance(w http.ResponseWriter, r *http.Request)
- func (h *MaintenanceHandler) GetMaintenance(w http.ResponseWriter, r *http.Request)
- func (h *MaintenanceHandler) UpdateMaintenance(w http.ResponseWriter, r *http.Request)
- type MaintenanceResponse
- type MonitorDTO
- type MonitorEvent
- type NotificationChannelsHandler
- func (h *NotificationChannelsHandler) CreateChannel(w http.ResponseWriter, r *http.Request)
- func (h *NotificationChannelsHandler) DeleteChannel(w http.ResponseWriter, r *http.Request)
- func (h *NotificationChannelsHandler) GetChannels(w http.ResponseWriter, r *http.Request)
- func (h *NotificationChannelsHandler) TestChannel(w http.ResponseWriter, r *http.Request)
- func (h *NotificationChannelsHandler) UpdateChannel(w http.ResponseWriter, r *http.Request)
- type OverviewResponse
- type Router
- type SSLWarningDTO
- type SSOHandler
- type SettingsHandler
- type SetupRequest
- type StatsHandler
- type StatusPageHandler
- func (h *StatusPageHandler) GetAll(w http.ResponseWriter, r *http.Request)
- func (h *StatusPageHandler) GetPublicStatus(w http.ResponseWriter, r *http.Request)
- func (h *StatusPageHandler) GetRSSFeed(w http.ResponseWriter, r *http.Request)
- func (h *StatusPageHandler) Toggle(w http.ResponseWriter, r *http.Request)
- type UpdateUserRequest
- type UptimeHandler
- func (h *UptimeHandler) GetHistory(w http.ResponseWriter, r *http.Request)
- func (h *UptimeHandler) GetMonitorLatency(w http.ResponseWriter, r *http.Request)
- func (h *UptimeHandler) GetMonitorUptime(w http.ResponseWriter, r *http.Request)
- func (h *UptimeHandler) GetOverview(w http.ResponseWriter, r *http.Request)
- type UptimeResponse
Constants ¶
const APIKeyUserID int64 = -1
APIKeyUserID is used to identify requests authenticated via API key SECURITY: Use -1 to distinguish from real user IDs (which are positive) This prevents authorization bypass if handlers assume userID > 0 means valid user
Variables ¶
var Version = "dev"
Version is injected at build time
Functions ¶
func Healthz ¶ added in v0.2.1
func Healthz(w http.ResponseWriter, r *http.Request)
Healthz is the liveness probe — confirms the process is running.
func RateLimitMiddleware ¶
func RateLimitMiddleware(limiter *IPRateLimiter) func(http.Handler) http.Handler
RateLimitMiddleware returns middleware that rate limits requests by IP.
func Readyz ¶ added in v0.2.1
func Readyz(store *db.Store) http.HandlerFunc
Readyz is the readiness probe — confirms the app can serve traffic.
func SecureHeadersWithConfig ¶
SecureHeadersWithConfig returns middleware that adds security headers including HSTS when HTTPS is enabled.
Types ¶
type APIKeyHandler ¶
type APIKeyHandler struct {
// contains filtered or unexported fields
}
func NewAPIKeyHandler ¶
func NewAPIKeyHandler(store *db.Store) *APIKeyHandler
func (*APIKeyHandler) CreateKey ¶
func (h *APIKeyHandler) CreateKey(w http.ResponseWriter, r *http.Request)
CreateKey generates a new API key. The raw key is returned only once. @Summary Create API key @Tags api-keys @Accept json @Produce json @Security BearerAuth @Param body body object{name=string} true "Key name" @Success 200 {object} object{key=string,message=string} @Failure 400 {object} object{error=string} "Name is required" @Router /api-keys [post]
func (*APIKeyHandler) DeleteKey ¶
func (h *APIKeyHandler) DeleteKey(w http.ResponseWriter, r *http.Request)
DeleteKey revokes an API key. @Summary Delete API key @Tags api-keys @Produce json @Security BearerAuth @Param id path int true "Key ID" @Success 200 {object} object{message=string} @Failure 400 {object} object{error=string} "Invalid ID" @Router /api-keys/{id} [delete]
func (*APIKeyHandler) ListKeys ¶
func (h *APIKeyHandler) ListKeys(w http.ResponseWriter, r *http.Request)
ListKeys returns all API keys (secrets are not included). @Summary List API keys @Tags api-keys @Produce json @Security BearerAuth @Success 200 {object} object{keys=[]db.APIKey} @Router /api-keys [get]
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
func NewAdminHandler ¶
func (*AdminHandler) ResetDatabase ¶
func (h *AdminHandler) ResetDatabase(w http.ResponseWriter, r *http.Request)
ResetDatabase performs a full database reset. This is a destructive operation that should only be used for testing/development. Accepts EITHER a valid session cookie (for frontend) OR admin secret (for E2E tests).
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(store *db.Store, cfg *config.Config, loginLimiter *LoginRateLimiter) *AuthHandler
func (*AuthHandler) AuthMiddleware ¶
func (h *AuthHandler) AuthMiddleware(next http.Handler) http.Handler
func (*AuthHandler) IsAuthenticated ¶
func (h *AuthHandler) IsAuthenticated(r *http.Request) bool
IsAuthenticated checks whether a request has a valid session cookie or API key without writing a response. Used by handlers that need optional auth checks.
func (*AuthHandler) Login ¶
func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request)
func (*AuthHandler) Logout ¶
func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)
func (*AuthHandler) Me ¶
func (h *AuthHandler) Me(w http.ResponseWriter, r *http.Request)
func (*AuthHandler) UpdateUser ¶
func (h *AuthHandler) UpdateUser(w http.ResponseWriter, r *http.Request)
type CRUDHandler ¶
type CRUDHandler struct {
// contains filtered or unexported fields
}
func NewCRUDHandler ¶
func NewCRUDHandler(store *db.Store, manager *uptime.Manager) *CRUDHandler
func (*CRUDHandler) CreateGroup ¶
func (h *CRUDHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
CreateGroup creates a new monitor group. @Summary Create group @Tags groups @Accept json @Produce json @Security BearerAuth @Param body body object{name=string} true "Group payload" @Success 201 {object} db.Group @Failure 400 {string} string "Name is required" @Failure 409 {object} object{error=string} "Group already exists" @Router /groups [post]
func (*CRUDHandler) CreateMonitor ¶
func (h *CRUDHandler) CreateMonitor(w http.ResponseWriter, r *http.Request)
CreateMonitor creates a new HTTP monitor. @Summary Create monitor @Tags monitors @Accept json @Produce json @Security BearerAuth @Param body body object{name=string,url=string,groupId=string,interval=int} true "Monitor payload" @Success 201 {object} db.Monitor @Failure 400 {string} string "Validation error" @Failure 404 {string} string "Group not found" @Failure 409 {string} string "Monitor name already exists" @Router /monitors [post]
func (*CRUDHandler) DeleteGroup ¶
func (h *CRUDHandler) DeleteGroup(w http.ResponseWriter, r *http.Request)
DeleteGroup deletes a monitor group by ID. @Summary Delete group @Tags groups @Produce json @Security BearerAuth @Param id path string true "Group ID" @Success 200 "OK" @Failure 400 {string} string "ID required" @Router /groups/{id} [delete]
func (*CRUDHandler) DeleteMonitor ¶
func (h *CRUDHandler) DeleteMonitor(w http.ResponseWriter, r *http.Request)
DeleteMonitor removes a monitor and its history. @Summary Delete monitor @Tags monitors @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Success 200 "OK" @Failure 400 {string} string "ID required" @Router /monitors/{id} [delete]
func (*CRUDHandler) GetGroups ¶
func (h *CRUDHandler) GetGroups(w http.ResponseWriter, r *http.Request)
func (*CRUDHandler) PauseMonitor ¶
func (h *CRUDHandler) PauseMonitor(w http.ResponseWriter, r *http.Request)
PauseMonitor stops checking a monitor without deleting it. @Summary Pause monitor @Tags monitors @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Success 200 {object} object{message=string,active=bool} @Failure 400 {object} object{error=string} "ID required" @Failure 404 {object} object{error=string} "Monitor not found" @Router /monitors/{id}/pause [post]
func (*CRUDHandler) ResumeMonitor ¶
func (h *CRUDHandler) ResumeMonitor(w http.ResponseWriter, r *http.Request)
ResumeMonitor restarts checking a paused monitor. @Summary Resume monitor @Tags monitors @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Success 200 {object} object{message=string,active=bool} @Failure 400 {object} object{error=string} "ID required" @Failure 404 {object} object{error=string} "Monitor not found" @Router /monitors/{id}/resume [post]
func (*CRUDHandler) UpdateGroup ¶
func (h *CRUDHandler) UpdateGroup(w http.ResponseWriter, r *http.Request)
UpdateGroup renames a monitor group. @Summary Update group @Tags groups @Accept json @Produce json @Security BearerAuth @Param id path string true "Group ID" @Param body body object{name=string} true "New name" @Success 200 {object} object{name=string} @Failure 400 {string} string "Name is required" @Router /groups/{id} [put]
func (*CRUDHandler) UpdateMonitor ¶
func (h *CRUDHandler) UpdateMonitor(w http.ResponseWriter, r *http.Request)
UpdateMonitor updates a monitor's name, URL, or interval. @Summary Update monitor @Tags monitors @Accept json @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Param body body object{name=string,url=string,interval=int} true "Fields to update" @Success 200 "OK" @Failure 400 {string} string "ID required" @Router /monitors/{id} [put]
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
func NewEventHandler ¶
func NewEventHandler(store *db.Store, manager *uptime.Manager) *EventHandler
func (*EventHandler) GetSystemEvents ¶
func (h *EventHandler) GetSystemEvents(w http.ResponseWriter, r *http.Request)
GetSystemEvents returns active outages, recent history, and SSL warnings. @Summary Get system events @Tags events @Produce json @Security BearerAuth @Success 200 {object} object{active=[]IncidentDTO,history=[]IncidentDTO,sslWarnings=[]SSLWarningDTO} @Failure 500 {object} object{error=string} @Router /events [get]
type GroupDTO ¶
type GroupDTO struct {
ID string `json:"id"`
Name string `json:"name"`
Monitors []MonitorDTO `json:"monitors"`
}
type GroupOverviewDTO ¶
type HistoryPoint ¶
type HistoryPoint struct {
Status string `json:"status"`
Latency int64 `json:"latency"`
Timestamp time.Time `json:"timestamp"`
StatusCode int `json:"statusCode"`
}
Response Structures matching Frontend Store
type IPRateLimiter ¶
type IPRateLimiter struct {
// contains filtered or unexported fields
}
IPRateLimiter manages rate limiters for individual IP addresses.
func NewIPRateLimiter ¶
func NewIPRateLimiter(r rate.Limit, b int) *IPRateLimiter
NewIPRateLimiter creates a new IP-based rate limiter. r is the rate (requests per second), b is the burst size.
func (*IPRateLimiter) GetLimiter ¶
func (i *IPRateLimiter) GetLimiter(ip string) *rate.Limiter
GetLimiter returns the rate limiter for the given IP address.
type IncidentDTO ¶
type IncidentDTO struct {
ID string `json:"id"`
MonitorID string `json:"monitorId"`
MonitorName string `json:"monitorName"`
GroupName string `json:"groupName"`
GroupID string `json:"groupId"`
Type string `json:"type"` // down, degraded, ssl_expiring
Message string `json:"message"`
StartedAt time.Time `json:"startedAt"`
ResolvedAt *time.Time `json:"resolvedAt"` // Null if active
Duration string `json:"duration"`
}
type IncidentHandler ¶
type IncidentHandler struct {
// contains filtered or unexported fields
}
func NewIncidentHandler ¶
func NewIncidentHandler(store *db.Store) *IncidentHandler
func (*IncidentHandler) AddUpdate ¶ added in v0.2.3
func (h *IncidentHandler) AddUpdate(w http.ResponseWriter, r *http.Request)
AddUpdate adds a status update to an incident timeline. @Summary Add incident update @Tags incidents @Accept json @Produce json @Security BearerAuth @Param id path string true "Incident ID" @Param body body object{status=string,message=string} true "Update details" @Success 201 {object} db.IncidentUpdate @Failure 400 {string} string "Invalid request body" @Failure 404 {string} string "Incident not found" @Router /incidents/{id}/updates [post]
func (*IncidentHandler) CreateIncident ¶
func (h *IncidentHandler) CreateIncident(w http.ResponseWriter, r *http.Request)
CreateIncident reports a new manual incident. @Summary Create incident @Tags incidents @Accept json @Produce json @Security BearerAuth @Param body body object{title=string,description=string,severity=string,status=string,startTime=string,affectedGroups=[]string} true "Incident payload" @Success 201 {object} db.Incident @Failure 400 {string} string "Invalid request body" @Router /incidents [post]
func (*IncidentHandler) DeleteIncident ¶ added in v0.2.3
func (h *IncidentHandler) DeleteIncident(w http.ResponseWriter, r *http.Request)
DeleteIncident deletes an incident. @Summary Delete incident @Tags incidents @Security BearerAuth @Param id path string true "Incident ID" @Success 204 @Failure 500 {string} string "Failed to delete incident" @Router /incidents/{id} [delete]
func (*IncidentHandler) GetIncident ¶ added in v0.2.3
func (h *IncidentHandler) GetIncident(w http.ResponseWriter, r *http.Request)
GetIncident returns a single incident with its timeline updates. @Summary Get incident with timeline @Tags incidents @Produce json @Security BearerAuth @Param id path string true "Incident ID" @Success 200 {object} IncidentResponseDTO @Failure 404 {string} string "Incident not found" @Router /incidents/{id} [get]
func (*IncidentHandler) GetIncidents ¶
func (h *IncidentHandler) GetIncidents(w http.ResponseWriter, r *http.Request)
GetIncidents returns incidents from the last 7 days. @Summary List incidents @Tags incidents @Produce json @Security BearerAuth @Success 200 {array} IncidentResponseDTO @Failure 500 {string} string "Failed to fetch incidents" @Router /incidents [get]
func (*IncidentHandler) GetUpdates ¶ added in v0.2.3
func (h *IncidentHandler) GetUpdates(w http.ResponseWriter, r *http.Request)
GetUpdates returns all updates for an incident. @Summary Get incident updates @Tags incidents @Produce json @Security BearerAuth @Param id path string true "Incident ID" @Success 200 {array} db.IncidentUpdate @Failure 404 {string} string "Incident not found" @Router /incidents/{id}/updates [get]
func (*IncidentHandler) PromoteOutage ¶ added in v0.2.3
func (h *IncidentHandler) PromoteOutage(w http.ResponseWriter, r *http.Request)
PromoteOutage creates an incident from an auto-detected outage. @Summary Promote outage to incident @Tags incidents @Accept json @Produce json @Security BearerAuth @Param id path string true "Outage ID" @Param body body object{title=string,description=string,severity=string,affectedGroups=[]string} true "Incident details" @Success 201 {object} IncidentResponseDTO @Failure 400 {string} string "Invalid request body" @Failure 404 {string} string "Outage not found" @Router /outages/{id}/promote [post]
func (*IncidentHandler) SetVisibility ¶ added in v0.2.3
func (h *IncidentHandler) SetVisibility(w http.ResponseWriter, r *http.Request)
SetVisibility toggles the public visibility of an incident. @Summary Set incident visibility @Tags incidents @Accept json @Produce json @Security BearerAuth @Param id path string true "Incident ID" @Param body body object{public=bool} true "Visibility setting" @Success 200 {object} object{message=string,public=bool} @Failure 400 {string} string "Invalid request body" @Failure 404 {string} string "Incident not found" @Router /incidents/{id}/visibility [patch]
func (*IncidentHandler) UpdateIncident ¶ added in v0.2.3
func (h *IncidentHandler) UpdateIncident(w http.ResponseWriter, r *http.Request)
UpdateIncident updates an existing incident. @Summary Update incident @Tags incidents @Accept json @Produce json @Security BearerAuth @Param id path string true "Incident ID" @Param body body object{title=string,description=string,severity=string,status=string,startTime=string,endTime=string,affectedGroups=[]string,public=bool} true "Incident payload" @Success 200 {object} IncidentResponseDTO @Failure 400 {string} string "Invalid request body" @Failure 404 {string} string "Incident not found" @Router /incidents/{id} [put]
type IncidentResponseDTO ¶ added in v0.2.3
type IncidentResponseDTO struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Type string `json:"type"`
Severity string `json:"severity"`
Status string `json:"status"`
StartTime time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime,omitempty"`
AffectedGroups []string `json:"affectedGroups"`
CreatedAt time.Time `json:"createdAt"`
Source string `json:"source"`
OutageID *int64 `json:"outageId,omitempty"`
Public bool `json:"public"`
Updates []db.IncidentUpdate `json:"updates,omitempty"`
}
IncidentResponseDTO is the API response structure for incidents
type LoginRateLimiter ¶
type LoginRateLimiter struct {
// contains filtered or unexported fields
}
LoginRateLimiter is a stricter rate limiter specifically for login attempts. It tracks failed attempts by both IP and username to prevent distributed attacks.
func NewLoginRateLimiter ¶
func NewLoginRateLimiter() *LoginRateLimiter
NewLoginRateLimiter creates a new login-specific rate limiter.
func (*LoginRateLimiter) Allow ¶
func (l *LoginRateLimiter) Allow(ip string) bool
Allow checks if a login attempt should be allowed for the given IP.
func (*LoginRateLimiter) AllowUsername ¶
func (l *LoginRateLimiter) AllowUsername(username string) bool
AllowUsername checks if a login attempt should be allowed for the given username. This prevents distributed brute force attacks against a single account.
func (*LoginRateLimiter) BlockDuration ¶
func (l *LoginRateLimiter) BlockDuration(ip string) time.Duration
BlockDuration returns how long the IP is blocked, or 0 if not blocked.
func (*LoginRateLimiter) RecordFailure ¶
func (l *LoginRateLimiter) RecordFailure(ip string)
RecordFailure records a failed login attempt and calculates the next block period.
func (*LoginRateLimiter) RecordSuccess ¶
func (l *LoginRateLimiter) RecordSuccess(ip string)
RecordSuccess clears the failure count for an IP after successful login.
func (*LoginRateLimiter) RecordUsernameFailure ¶
func (l *LoginRateLimiter) RecordUsernameFailure(username string)
RecordUsernameFailure records a failed login attempt for a specific username. Uses longer backoff since distributed attacks can use many IPs.
func (*LoginRateLimiter) RecordUsernameSuccess ¶
func (l *LoginRateLimiter) RecordUsernameSuccess(username string)
RecordUsernameSuccess clears the failure count for a username after successful login.
func (*LoginRateLimiter) UsernameBlockDuration ¶
func (l *LoginRateLimiter) UsernameBlockDuration(username string) time.Duration
UsernameBlockDuration returns how long the username is blocked, or 0 if not blocked.
type LoginRequest ¶
type MaintenanceHandler ¶
type MaintenanceHandler struct {
// contains filtered or unexported fields
}
func NewMaintenanceHandler ¶
func NewMaintenanceHandler(store *db.Store, manager *uptime.Manager) *MaintenanceHandler
func (*MaintenanceHandler) CreateMaintenance ¶
func (h *MaintenanceHandler) CreateMaintenance(w http.ResponseWriter, r *http.Request)
CreateMaintenance schedules a new maintenance window. @Summary Create maintenance @Tags maintenance @Accept json @Produce json @Security BearerAuth @Param body body object{title=string,description=string,status=string,startTime=string,endTime=string,affectedGroups=[]string} true "Maintenance payload" @Success 201 {object} MaintenanceResponse @Failure 400 {string} string "Invalid request body" @Failure 500 {string} string "Failed to schedule maintenance" @Router /maintenance [post]
func (*MaintenanceHandler) DeleteMaintenance ¶
func (h *MaintenanceHandler) DeleteMaintenance(w http.ResponseWriter, r *http.Request)
DeleteMaintenance removes a maintenance window. @Summary Delete maintenance @Tags maintenance @Produce json @Security BearerAuth @Param id path string true "Maintenance ID" @Success 200 {object} object{success=bool} @Failure 400 {string} string "Maintenance ID required" @Failure 500 {string} string "Failed to delete maintenance" @Router /maintenance/{id} [delete]
func (*MaintenanceHandler) GetMaintenance ¶
func (h *MaintenanceHandler) GetMaintenance(w http.ResponseWriter, r *http.Request)
GetMaintenance returns all maintenance windows. @Summary List maintenance windows @Tags maintenance @Produce json @Security BearerAuth @Success 200 {array} MaintenanceResponse @Failure 500 {string} string "Failed to fetch maintenance events" @Router /maintenance [get]
func (*MaintenanceHandler) UpdateMaintenance ¶
func (h *MaintenanceHandler) UpdateMaintenance(w http.ResponseWriter, r *http.Request)
UpdateMaintenance modifies an existing maintenance window. @Summary Update maintenance @Tags maintenance @Accept json @Produce json @Security BearerAuth @Param id path string true "Maintenance ID" @Param body body object{title=string,description=string,status=string,startTime=string,endTime=string,affectedGroups=[]string} true "Updated maintenance" @Success 200 {object} MaintenanceResponse @Failure 400 {string} string "Invalid request body" @Failure 500 {string} string "Failed to update maintenance" @Router /maintenance/{id} [put]
type MaintenanceResponse ¶
type MaintenanceResponse struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Type string `json:"type"`
Severity string `json:"severity"`
Status string `json:"status"`
StartTime time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime,omitempty"`
AffectedGroups []string `json:"affectedGroups"`
CreatedAt time.Time `json:"createdAt"`
}
type MonitorDTO ¶
type MonitorDTO struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Status string `json:"status"`
Active bool `json:"active"`
Latency int64 `json:"latency"`
Interval int `json:"interval"`
History []HistoryPoint `json:"history"`
Events []MonitorEvent `json:"events"`
LastCheck string `json:"lastCheck"`
ConfirmationThreshold *int `json:"confirmationThreshold,omitempty"`
NotificationCooldownMin *int `json:"notificationCooldownMinutes,omitempty"`
}
type MonitorEvent ¶
type NotificationChannelsHandler ¶
type NotificationChannelsHandler struct {
// contains filtered or unexported fields
}
func NewNotificationChannelsHandler ¶
func NewNotificationChannelsHandler(store *db.Store) *NotificationChannelsHandler
func (*NotificationChannelsHandler) CreateChannel ¶
func (h *NotificationChannelsHandler) CreateChannel(w http.ResponseWriter, r *http.Request)
CreateChannel adds a new notification channel (e.g. Slack webhook). @Summary Create notification channel @Tags notifications @Accept json @Produce json @Security BearerAuth @Param body body object{type=string,name=string,config=object,enabled=bool} true "Channel config" @Success 201 {object} db.NotificationChannel @Failure 400 {string} string "Type and Name are required" @Router /notifications/channels [post]
func (*NotificationChannelsHandler) DeleteChannel ¶
func (h *NotificationChannelsHandler) DeleteChannel(w http.ResponseWriter, r *http.Request)
DeleteChannel removes a notification channel. @Summary Delete notification channel @Tags notifications @Produce json @Security BearerAuth @Param id path string true "Channel ID" @Success 200 "OK" @Failure 400 {string} string "Missing ID" @Router /notifications/channels/{id} [delete]
func (*NotificationChannelsHandler) GetChannels ¶
func (h *NotificationChannelsHandler) GetChannels(w http.ResponseWriter, r *http.Request)
GetChannels returns all configured notification channels. @Summary List notification channels @Tags notifications @Produce json @Security BearerAuth @Success 200 {object} object{channels=[]db.NotificationChannel} @Failure 500 {string} string "Failed to fetch channels" @Router /notifications/channels [get]
func (*NotificationChannelsHandler) TestChannel ¶ added in v0.2.4
func (h *NotificationChannelsHandler) TestChannel(w http.ResponseWriter, r *http.Request)
TestChannel sends a test notification through the specified channel type and config.
func (*NotificationChannelsHandler) UpdateChannel ¶ added in v0.2.4
func (h *NotificationChannelsHandler) UpdateChannel(w http.ResponseWriter, r *http.Request)
UpdateChannel modifies an existing notification channel.
type OverviewResponse ¶
type OverviewResponse struct {
Groups []GroupOverviewDTO `json:"groups"`
}
type Router ¶
func (*Router) CheckSetup ¶
func (h *Router) CheckSetup(w http.ResponseWriter, r *http.Request)
func (*Router) PerformSetup ¶
func (h *Router) PerformSetup(w http.ResponseWriter, r *http.Request)
type SSLWarningDTO ¶
type SSLWarningDTO struct {
ID string `json:"id"`
MonitorID string `json:"monitorId"`
MonitorName string `json:"monitorName"`
GroupName string `json:"groupName"`
GroupID string `json:"groupId"`
Type string `json:"type"` // always "ssl_expiring"
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
type SSOHandler ¶
type SSOHandler struct {
// contains filtered or unexported fields
}
func NewSSOHandler ¶
func NewSSOHandler(store *db.Store, cfg *config.Config) *SSOHandler
func (*SSOHandler) GetSSOStatus ¶
func (h *SSOHandler) GetSSOStatus(w http.ResponseWriter, r *http.Request)
GetSSOStatus returns the status of configured SSO providers (public endpoint)
func (*SSOHandler) GoogleCallback ¶
func (h *SSOHandler) GoogleCallback(w http.ResponseWriter, r *http.Request)
GoogleCallback handles the OAuth callback from Google
func (*SSOHandler) GoogleLogin ¶
func (h *SSOHandler) GoogleLogin(w http.ResponseWriter, r *http.Request)
GoogleLogin initiates the Google OAuth flow
func (*SSOHandler) TestSSOConfig ¶
func (h *SSOHandler) TestSSOConfig(w http.ResponseWriter, r *http.Request)
TestSSOConfig tests if the SSO configuration is valid (admin only)
type SettingsHandler ¶
type SettingsHandler struct {
// contains filtered or unexported fields
}
func NewSettingsHandler ¶
func NewSettingsHandler(store *db.Store, manager *uptime.Manager) *SettingsHandler
func (*SettingsHandler) GetSettings ¶
func (h *SettingsHandler) GetSettings(w http.ResponseWriter, r *http.Request)
GetSettings returns all application settings (secrets are masked). @Summary Get settings @Tags settings @Produce json @Security BearerAuth @Success 200 {object} map[string]string @Router /settings [get]
func (*SettingsHandler) UpdateSettings ¶
func (h *SettingsHandler) UpdateSettings(w http.ResponseWriter, r *http.Request)
UpdateSettings patches application settings. @Summary Update settings @Tags settings @Accept json @Produce json @Security BearerAuth @Param body body map[string]string true "Key-value pairs to update" @Success 200 {object} object{status=string} @Failure 400 {string} string "Invalid body" @Router /settings [patch]
type SetupRequest ¶
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
func NewStatsHandler ¶
func NewStatsHandler(store *db.Store) *StatsHandler
func (*StatsHandler) GetStats ¶
func (h *StatsHandler) GetStats(w http.ResponseWriter, r *http.Request)
GetStats returns system statistics including monitor counts and DB size. @Summary Get system stats @Tags stats @Produce json @Security BearerAuth @Success 200 {object} object{version=string,dbSize=int,stats=db.SystemStats} @Failure 500 {string} string "Failed to get stats" @Router /stats [get]
type StatusPageHandler ¶
type StatusPageHandler struct {
// contains filtered or unexported fields
}
func NewStatusPageHandler ¶
func NewStatusPageHandler(store *db.Store, manager *uptime.Manager, auth *AuthHandler) *StatusPageHandler
func (*StatusPageHandler) GetAll ¶
func (h *StatusPageHandler) GetAll(w http.ResponseWriter, r *http.Request)
GetAll returns all status page configurations merged with groups. @Summary List status pages @Tags status-pages @Produce json @Security BearerAuth @Success 200 {object} object{pages=[]object{slug=string,title=string,groupId=string,public=bool}} @Failure 500 {object} object{error=string} @Router /status-pages [get]
func (*StatusPageHandler) GetPublicStatus ¶
func (h *StatusPageHandler) GetPublicStatus(w http.ResponseWriter, r *http.Request)
GetPublicStatus returns real-time status data for a public status page. @Summary Public status page @Tags status-pages @Produce json @Param slug path string true "Status page slug" @Success 200 {object} object{title=string,public=bool,groups=[]object{id=string,name=string},incidents=[]object{id=string,title=string}} @Failure 403 {object} object{error=string} "Status page is private" @Failure 404 {object} object{error=string} "Status page not found" @Router /s/{slug} [get]
func (*StatusPageHandler) GetRSSFeed ¶ added in v0.2.3
func (h *StatusPageHandler) GetRSSFeed(w http.ResponseWriter, r *http.Request)
GetRSSFeed returns an RSS 2.0 feed of recent incidents for a public status page. @Summary RSS feed for status page @Tags status-pages @Produce application/rss+xml @Param slug path string true "Status page slug" @Success 200 {string} string "RSS 2.0 XML feed" @Failure 404 {object} object{error=string} "Status page not found" @Router /s/{slug}/rss [get]
func (*StatusPageHandler) Toggle ¶
func (h *StatusPageHandler) Toggle(w http.ResponseWriter, r *http.Request)
Toggle enables or disables a public status page. @Summary Toggle status page @Tags status-pages @Accept json @Produce json @Security BearerAuth @Param slug path string true "Status page slug" @Param body body object{public=bool,title=string,groupId=string} true "Toggle payload" @Success 200 {object} object{message=string} @Failure 400 {object} object{error=string} "Invalid request" @Router /status-pages/{slug} [patch]
type UpdateUserRequest ¶
type UptimeHandler ¶
type UptimeHandler struct {
// contains filtered or unexported fields
}
func NewUptimeHandler ¶
func NewUptimeHandler(manager *uptime.Manager, store *db.Store) *UptimeHandler
func (*UptimeHandler) GetHistory ¶
func (h *UptimeHandler) GetHistory(w http.ResponseWriter, r *http.Request)
GetHistory returns all monitors grouped by group with ping history. @Summary List monitors with history @Tags uptime @Produce json @Security BearerAuth @Param group_id query string false "Filter by group ID" @Success 200 {object} UptimeResponse @Failure 500 {string} string "Internal error" @Router /uptime [get]
func (*UptimeHandler) GetMonitorLatency ¶
func (h *UptimeHandler) GetMonitorLatency(w http.ResponseWriter, r *http.Request)
GetMonitorLatency returns latency datapoints over a time range. @Summary Get monitor latency history @Tags uptime @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Param range query string false "Time range: 1h, 24h, 7d, 30d (default 24h)" @Success 200 {array} db.CheckResult @Failure 400 {string} string "ID required" @Failure 500 {string} string "Failed to fetch latency stats" @Router /monitors/{id}/latency [get]
func (*UptimeHandler) GetMonitorUptime ¶
func (h *UptimeHandler) GetMonitorUptime(w http.ResponseWriter, r *http.Request)
GetMonitorUptime returns uptime percentages for 24h, 7d, and 30d. @Summary Get monitor uptime stats @Tags uptime @Produce json @Security BearerAuth @Param id path string true "Monitor ID" @Success 200 {object} object{uptime24h=number,uptime7d=number,uptime30d=number} @Failure 400 {string} string "ID required" @Failure 500 {string} string "Failed to calculate stats" @Router /monitors/{id}/uptime [get]
func (*UptimeHandler) GetOverview ¶
func (h *UptimeHandler) GetOverview(w http.ResponseWriter, r *http.Request)
GetOverview returns a high-level status for each group. @Summary Dashboard overview @Tags uptime @Produce json @Security BearerAuth @Success 200 {object} OverviewResponse @Failure 500 {string} string "Internal error" @Router /overview [get]
type UptimeResponse ¶
type UptimeResponse struct {
Groups []GroupDTO `json:"groups"`
}
Source Files
¶
- auth.go
- handlers_admin.go
- handlers_apikeys.go
- handlers_crud.go
- handlers_events.go
- handlers_health.go
- handlers_incidents.go
- handlers_maintenance.go
- handlers_notifications.go
- handlers_settings.go
- handlers_setup.go
- handlers_sso.go
- handlers_stats.go
- handlers_status_pages.go
- handlers_uptime.go
- ratelimit.go
- router.go
- sanitize.go
- version.go