diff --git a/apps/carrier-connector/main.go b/apps/carrier-connector/main.go index 75a3e51..1a4b692 100644 --- a/apps/carrier-connector/main.go +++ b/apps/carrier-connector/main.go @@ -11,6 +11,7 @@ import ( "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/es2" handler "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/handler" "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository" + "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/webhook" "github.com/rs/zerolog" ) @@ -56,7 +57,12 @@ func main() { profileRepo := repository.NewCachedProfileStore(postgresRepo, 5*time.Minute) defer profileRepo.Close() - setupRoutes(router, client, profileRepo) + // Initialize webhook client for api-server notifications + webhookURL := handler.GetEnv("API_SERVER_WEBHOOK_URL", "") + webhookAPIKey := handler.GetEnv("API_SERVER_WEBHOOK_API_KEY", "") + webhookClient := webhook.NewWebhookClient(webhookURL, webhookAPIKey) + + setupRoutes(router, client, profileRepo, webhookClient) handler.Logger.Info().Str("port", port).Msg("Carrier Connector API server starting") if err := router.Run(":" + port); err != nil { diff --git a/apps/carrier-connector/routes.go b/apps/carrier-connector/routes.go index 1fc8d57..b41a558 100644 --- a/apps/carrier-connector/routes.go +++ b/apps/carrier-connector/routes.go @@ -10,10 +10,11 @@ import ( "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/es2" handler "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/handler" "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository" + "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/webhook" ) -// setupRoutes registers all HTTP routes, wiring the ES2+ client and profile repo. -func setupRoutes(router *gin.Engine, client *es2.ES2Client, repo repository.ProfileRepository) { +// setupRoutes registers all HTTP routes, wiring the ES2+ client, profile repo, and webhook client. +func setupRoutes(router *gin.Engine, client *es2.ES2Client, repo repository.ProfileRepository, webhookClient *webhook.WebhookClient) { api := router.Group("/api/v1") api.GET("/health", healthHandler) api.GET("/health/ready", readinessHandler(repo)) @@ -22,10 +23,10 @@ func setupRoutes(router *gin.Engine, client *es2.ES2Client, repo repository.Prof esim := api.Group("/esim") { - esim.POST("/profiles", handler.OrderProfileHandlerWithRepo(client, repo)) + esim.POST("/profiles", handler.OrderProfileHandlerWithRepo(client, repo, webhookClient)) esim.GET("/profiles", handler.ListProfilesHandlerWithRepo(repo)) esim.GET("/profiles/:profileId", handler.GetProfileHandlerWithRepo(client, repo)) - esim.DELETE("/profiles/:profileId", handler.DeleteProfileHandlerWithRepo(client, repo)) + esim.DELETE("/profiles/:profileId", handler.DeleteProfileHandlerWithRepo(client, repo, webhookClient)) } carrier := api.Group("/carrier")