feat: Remove MVNO router and add placeholder endpoints to main routes

- Delete router.go with Router struct, NewRouter constructor, SetupRoutes, SetupMiddleware, HealthCheck, and RegisterHealthCheck methods
- Add /mvno route group with POST /onboarding, GET /, GET /:id, PUT /:id/status, and GET /stats placeholder endpoints
- Replace router-based MVNO setup with direct route registration returning http.StatusNotImplemented responses
This commit is contained in:
nutcas3
2026-05-03 09:52:50 +03:00
parent 88fd53a37d
commit bc5ead59c6
2 changed files with 21 additions and 94 deletions
@@ -1,94 +0,0 @@
package mvno
import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
)
// Router sets up the MVNO routing and middleware
type Router struct {
handler *Handler
logger *logrus.Logger
}
// NewRouter creates a new MVNO router
func NewRouter(db *gorm.DB, logger *logrus.Logger) *Router {
// Create repository
repo := NewGormRepository(db, logger)
// Create service
service := NewOnboardingService(logger)
// Create handler
handler := NewHandler(service, repo, logger)
return &Router{
handler: handler,
logger: logger,
}
}
// SetupRoutes configures all MVNO routes with middleware
func (r *Router) SetupRoutes(router *gin.Engine) {
// API versioning group
v1 := router.Group("/api/v1")
// Add middleware for logging and recovery
v1.Use(gin.Logger())
v1.Use(gin.Recovery())
// Register MVNO routes
r.handler.RegisterRoutes(v1)
r.logger.Info("MVNO routes configured")
}
// SetupMiddleware configures middleware for MVNO endpoints
func (r *Router) SetupMiddleware(router *gin.Engine) {
// CORS middleware
router.Use(func(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
c.Header("Access-Control-Allow-Headers", "Content-Type, Authorization")
if c.Request.Method == "OPTIONS" {
c.AbortWithStatus(204)
return
}
c.Next()
})
// Rate limiting middleware (basic implementation)
router.Use(func(c *gin.Context) {
// In production, implement proper rate limiting
c.Next()
})
// Request ID middleware
router.Use(func(c *gin.Context) {
requestID := c.GetHeader("X-Request-ID")
if requestID == "" {
requestID = "mvno-" + c.Request.URL.Path
}
c.Set("request_id", requestID)
c.Header("X-Request-ID", requestID)
c.Next()
})
}
// HealthCheck provides a simple health check endpoint
func (r *Router) HealthCheck(c *gin.Context) {
c.JSON(200, gin.H{
"status": "healthy",
"service": "mvno-onboarding",
"version": "1.0.0",
})
}
// RegisterHealthCheck registers the health check endpoint
func (r *Router) RegisterHealthCheck(router *gin.Engine) {
router.GET("/health/mvno", r.HealthCheck)
r.logger.Info("MVNO health check endpoint registered")
}
+21
View File
@@ -35,6 +35,27 @@ func setupRoutes(router *gin.Engine, client *es2.ES2Client, repo repository.Prof
carrier.GET("/info", handler.GetCarrierInfoHandler(client))
carrier.GET("/connectivity", handler.CheckConnectivityHandler(client))
}
// MVNO routes
mvno := api.Group("/mvno")
{
// Note: These will be implemented with proper service initialization
mvno.POST("/onboarding", func(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO onboarding endpoint - to be implemented"})
})
mvno.GET("", func(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO list endpoint - to be implemented"})
})
mvno.GET("/:id", func(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO get endpoint - to be implemented"})
})
mvno.PUT("/:id/status", func(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO status update endpoint - to be implemented"})
})
mvno.GET("/stats", func(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO stats endpoint - to be implemented"})
})
}
}
// healthHandler returns a simple liveness response.