server Package
Overview
Package server provides the HTTP server implementation for the incident management platform.
This package contains the main HTTP server that handles all REST API endpoints, WebSocket connections, Server-Sent Events, and webhook integrations. The server orchestrates all platform services and provides a unified interface for client applications.
Key Features:
- RESTful API for incident management operations
- Real-time WebSocket and SSE connections for live updates
- Webhook endpoints for external system integrations
- Authentication and authorization middleware
- SCIM 2.0 server for automated user provisioning
- Comprehensive metrics and analytics endpoints
- Push notification management
- ChatOps integration endpoints
Architecture:
The server follows a layered architecture with clear separation of concerns:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ HTTP Handlers │◄──►│ Service Layer │◄──►│ Storage Layer │
│ (REST/WS/SSE) │ │ (Business Logic) │ │ (Database) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Authentication │ │ Real-time │ │ External │
│ & Authorization │ │ Notifications │ │ Integrations │
└─────────────────┘ └──────────────────┘ └─────────────────┘
Example usage:
// Create and start the server
config := server.Config{
Port: "8080",
Dev: false,
}
srv, err := server.New(config)
if err != nil {
log.Fatal(err)
}
log.Printf("Starting incident management server on port %s", config.Port)
if err := srv.Start(); err != nil {
log.Fatal(err)
}
Import Path: github.com/systmms/incidents/internal/server
Types
ChatOpsHandler
{<nil> 39755 type 0 [0x140006355c0] 0}Methods
NewChatOpsHandler
{<nil> <nil> NewChatOpsHandler 0x14000802ee0 <nil>}Config
Config holds server configuration parameters.
The configuration controls basic server behavior and can be extended to support additional deployment-specific settings.
{<nil> 80133 type 0 [0x1400078ad00] 0}ConnectorHandler
{<nil> 39203 type 0 [0x14000634e80] 0}Methods
NewConnectorHandler
{<nil> <nil> NewConnectorHandler 0x14000802800 <nil>}EnhancedConfig
EnhancedConfig holds enhanced server configuration
{<nil> 26223 type 0 [0x140006b7500] 0}EnhancedServer
EnhancedServer represents the HTTP server with Centrifuge integration
{<nil> 25521 type 0 [0x140006b7080] 0}Methods
NewEnhanced
NewEnhanced creates a new enhanced server instance with Centrifuge integration
{<nil> <nil> NewEnhanced 0x14000792100 <nil>}EscalationHandler
{<nil> 37903 type 0 [0x14000634300] 0}Methods
NewEscalationHandler
{<nil> <nil> NewEscalationHandler 0x14000713960 <nil>}MetricsHandler
{<nil> 38693 type 0 [0x14000634900] 0}Methods
NewMetricsHandler
{<nil> <nil> NewMetricsHandler 0x14000802120 <nil>}PagerDutyAssignee
{<nil> 54376 type 0 [0x140006889c0] 0}PagerDutyAssignment
{<nil> 54293 type 0 [0x14000688900] 0}PagerDutyEscalationPolicy
{<nil> 54189 type 0 [0x14000688800] 0}PagerDutyIncident
{<nil> 53562 type 0 [0x14000688300] 0}PagerDutyMessage
{<nil> 53343 type 0 [0x14000688180] 0}PagerDutyService
{<nil> 54094 type 0 [0x14000688700] 0}PagerDutyWebhook
PagerDuty webhook data structures
{<nil> 53262 type 0 [0x14000655e80] 0}PushHandler
{<nil> 40265 type 0 [0x14000635a40] 0}Methods
NewPushHandler
{<nil> <nil> NewPushHandler 0x140008035c0 <nil>}SLAHandler
{<nil> 37457 type 0 [0x14000885d00] 0}Methods
NewSLAHandler
{<nil> <nil> NewSLAHandler 0x14000713160 <nil>}Server
Server represents the main HTTP server for the incident management platform.
The server coordinates all platform services and provides a unified API interface. It handles HTTP requests, WebSocket connections, Server-Sent Events, and integrates with external systems through webhooks and connectors.
The server maintains references to all major platform services and orchestrates their interactions to provide comprehensive incident management functionality.
{<nil> 80805 type 0 [0x1400078af40] 0}Methods
New
New creates a new server instance with the specified configuration.
This constructor initializes all platform services in the correct order to handle dependencies between services. The initialization process includes:
- Database connection and schema setup
- Real-time notification infrastructure (WebSocket, SSE, Broadcasting)
- Core services (Timeline, Correlation, SLA, Metrics)
- Integration services (Connectors, ChatOps, Push Notifications)
- Authentication and SCIM services
- HTTP routing configuration
The function performs extensive error checking during initialization and will return an error if any critical service fails to start properly.
Environment Variables:
- JWT_SECRET: Secret key for JWT token signing (required)
- ADMIN_PASSWORD: Default admin user password (required)
- JWT_EXPIRATION: JWT token expiration duration (optional, default: 24h)
- GORUSH_URL: Push notification service URL (optional)
- BASE_URL: Base URL for SCIM endpoints (optional)
Returns an error if database connection fails, service initialization fails, or required environment variables are missing.
{<nil> <nil> New 0x14000264200 <nil>}Functions
classifyIncidentData
classifyIncidentData extracts sensitive data fields from incident TODO: Implement data classification
{<nil> <nil> classifyIncidentData 0x14000432b20 <nil>}getActor
getActor extracts actor information from PagerDuty message
{<nil> <nil> getActor 0x14000686b80 <nil>}getEnvOrDefault
{<nil> <nil> getEnvOrDefault 0x14000803ce0 <nil>}isValidTimeFormat
isValidTimeFormat checks if time is in HH:MM format
{<nil> <nil> isValidTimeFormat 0x140000b15a0 <nil>}parseTimeRange
parseTimeRange parses start/end time parameters from HTTP request query parameters.
This utility function handles various time range formats commonly used in analytics and metrics endpoints:
- Absolute time ranges using “since” and “until” parameters (RFC3339 format)
- Relative time ranges using “range” parameter with predefined values
- Default behavior (last 7 days if no parameters provided)
Supported relative ranges:
- “1h”: Last 1 hour
- “24h”: Last 24 hours
- “7d”: Last 7 days (default)
- “30d”: Last 30 days
- “90d”: Last 90 days
Parameters:
- since: Start time in RFC3339 format (e.g., “2023-01-01T00:00:00Z”)
- until: End time in RFC3339 format (defaults to current time)
- range: Relative time range (overrides since/until if provided)
Returns start time and end time for the requested range.
{<nil> <nil> parseTimeRange 0x140003f8b00 <nil>}redactIncidentFields
redactIncidentFields removes sensitive fields based on policy decision TODO: Implement field-level redaction
{<nil> <nil> redactIncidentFields 0x14000432e80 <nil>}Generated automatically from Go source code. Last updated: 2025-08-25T07:51:05-04:00