Documentation
ΒΆ
Index ΒΆ
- Constants
- func AuthMiddleware(jwtSecret string, next http.HandlerFunc) http.HandlerFunc
- func CORSMiddleware(next http.Handler) http.Handler
- func GetUserIDFromContext(r *http.Request) (uuid.UUID, error)
- func JSONError(w http.ResponseWriter, statusCode int, message string)
- func JSONResponse(w http.ResponseWriter, statusCode int, data interface{})
- func RateLimitMiddleware(requestsPerSec int, next http.HandlerFunc) http.HandlerFunc
- type APIHandler
- func (h *APIHandler) CreateMonitorHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) DeleteMonitorHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) GetMonitorHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) GetMonitorIncidentsHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) GetMonitorLogsHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) ListMonitorsHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) LoginHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) PublicStatusHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) SetupRouter() http.Handler
- func (h *APIHandler) SignupHandler(w http.ResponseWriter, r *http.Request)
- func (h *APIHandler) UpdateMonitorHandler(w http.ResponseWriter, r *http.Request)
- type AuthRequest
- type AuthResponse
- type CreateMonitorRequest
- type PublicIncidentReport
- type PublicMonitorCard
- type PublicStatusResponse
- type ResponseEnvelope
- type UpdateMonitorRequest
Constants ΒΆ
const ( UserIDContextKey contextKey = "user_id" UserEmailContextKey contextKey = "user_email" )
Variables ΒΆ
This section is empty.
Functions ΒΆ
func AuthMiddleware ΒΆ
func AuthMiddleware(jwtSecret string, next http.HandlerFunc) http.HandlerFunc
AuthMiddleware validates JWT Bearer tokens and attaches UserID to request context.
func CORSMiddleware ΒΆ
CORSMiddleware enables Cross-Origin Resource Sharing headers for Web Dashboard requests.
func GetUserIDFromContext ΒΆ
GetUserIDFromContext retrieves the authenticated UserID from request context.
func JSONError ΒΆ
func JSONError(w http.ResponseWriter, statusCode int, message string)
JSONError sends a JSON response formatted error message.
func JSONResponse ΒΆ
func JSONResponse(w http.ResponseWriter, statusCode int, data interface{})
JSONResponse sends a JSON response with status code and data payload.
func RateLimitMiddleware ΒΆ added in v0.3.0
func RateLimitMiddleware(requestsPerSec int, next http.HandlerFunc) http.HandlerFunc
RateLimitMiddleware enforces a sliding-window rate limit (requestsPerSec) per client IP address.
Types ΒΆ
type APIHandler ΒΆ
func NewAPIHandler ΒΆ
func NewAPIHandler(database *gorm.DB, cfg *config.Config) *APIHandler
func (*APIHandler) CreateMonitorHandler ΒΆ
func (h *APIHandler) CreateMonitorHandler(w http.ResponseWriter, r *http.Request)
CreateMonitorHandler creates a new monitor target for the authenticated tenant.
func (*APIHandler) DeleteMonitorHandler ΒΆ
func (h *APIHandler) DeleteMonitorHandler(w http.ResponseWriter, r *http.Request)
DeleteMonitorHandler removes a monitor target.
func (*APIHandler) GetMonitorHandler ΒΆ
func (h *APIHandler) GetMonitorHandler(w http.ResponseWriter, r *http.Request)
GetMonitorHandler fetches details for a specific monitor.
func (*APIHandler) GetMonitorIncidentsHandler ΒΆ
func (h *APIHandler) GetMonitorIncidentsHandler(w http.ResponseWriter, r *http.Request)
GetMonitorIncidentsHandler returns outage incident history for a monitor.
func (*APIHandler) GetMonitorLogsHandler ΒΆ
func (h *APIHandler) GetMonitorLogsHandler(w http.ResponseWriter, r *http.Request)
GetMonitorLogsHandler returns recent PingLog execution telemetry for a monitor.
func (*APIHandler) ListMonitorsHandler ΒΆ
func (h *APIHandler) ListMonitorsHandler(w http.ResponseWriter, r *http.Request)
ListMonitorsHandler lists all monitors owned by the authenticated tenant.
func (*APIHandler) LoginHandler ΒΆ
func (h *APIHandler) LoginHandler(w http.ResponseWriter, r *http.Request)
LoginHandler authenticates user credentials and returns a JWT token.
func (*APIHandler) PublicStatusHandler ΒΆ
func (h *APIHandler) PublicStatusHandler(w http.ResponseWriter, r *http.Request)
PublicStatusHandler returns an unauthenticated system operational summary for public status pages.
func (*APIHandler) SetupRouter ΒΆ
func (h *APIHandler) SetupRouter() http.Handler
SetupRouter initializes the HTTP router and registers all public and authenticated REST endpoints.
func (*APIHandler) SignupHandler ΒΆ
func (h *APIHandler) SignupHandler(w http.ResponseWriter, r *http.Request)
SignupHandler handles new tenant user registration.
func (*APIHandler) UpdateMonitorHandler ΒΆ
func (h *APIHandler) UpdateMonitorHandler(w http.ResponseWriter, r *http.Request)
UpdateMonitorHandler updates monitor parameters or status.
type AuthRequest ΒΆ
type AuthResponse ΒΆ
type CreateMonitorRequest ΒΆ
type PublicIncidentReport ΒΆ
type PublicMonitorCard ΒΆ
type PublicStatusResponse ΒΆ
type PublicStatusResponse struct {
SystemStatus string `json:"system_status"` // "All Systems Operational" or "Partial System Outage"
TotalMonitors int `json:"total_monitors"`
UpMonitors int `json:"up_monitors"`
DownMonitors int `json:"down_monitors"`
Monitors []PublicMonitorCard `json:"monitors"`
ActiveIncidents []PublicIncidentReport `json:"active_incidents"`
}
type ResponseEnvelope ΒΆ
type ResponseEnvelope struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Response Envelope for standardized REST API JSON responses.
type UpdateMonitorRequest ΒΆ
type UpdateMonitorRequest struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
CheckIntervalSeconds int `json:"check_interval_seconds,omitempty"`
Status db.MonitorStatus `json:"status,omitempty"`
WebhookURL string `json:"webhook_url,omitempty"`
IsPublic *bool `json:"is_public,omitempty"`
}