mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-21 12:14:28 +00:00
feat: Add webhook client initialization and integration to carrier connector routes
- Add webhook package import to main.go and routes.go - Add API_SERVER_WEBHOOK_URL and API_SERVER_WEBHOOK_API_KEY environment variable loading - Add webhookClient initialization with NewWebhookClient in main function - Add webhookClient parameter to setupRoutes function signature and comment - Pass webhookClient to OrderProfileHandlerWithRepo and DeleteProfileHandlerWithRepo routes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user