Initial commit: 网络验证平台
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"verification-platform-backend/internal/middleware"
|
||||
"verification-platform-backend/internal/router/app"
|
||||
"verification-platform-backend/internal/router/developer"
|
||||
"verification-platform-backend/internal/router/extension"
|
||||
"verification-platform-backend/internal/router/frontend"
|
||||
"verification-platform-backend/pkg/response"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SetupRoutes(r *gin.Engine) {
|
||||
r.Use(middleware.Cors())
|
||||
r.Use(middleware.Logger())
|
||||
|
||||
r.GET("/health", func(c *gin.Context) {
|
||||
response.Success(c, gin.H{
|
||||
"status": "ok",
|
||||
"time": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
})
|
||||
|
||||
frontend.SetupRoutes(r)
|
||||
|
||||
api := r.Group("/api/v1")
|
||||
{
|
||||
devGroup := api.Group("/dev")
|
||||
{
|
||||
devGroup.Use(middleware.JWT())
|
||||
devGroup.Use(middleware.DeveloperAuth())
|
||||
developer.SetupRoutes(devGroup)
|
||||
developer.SetupRoutesWithoutPackage(devGroup)
|
||||
}
|
||||
|
||||
appGroup := api.Group("/app/:appKey")
|
||||
{
|
||||
appGroup.Use(app.AppCryptoMiddleware())
|
||||
appGroup.Use(app.ResponseEncryption())
|
||||
app.SetupInfoRoutes(appGroup)
|
||||
}
|
||||
|
||||
appGroupWithStatusCheck := api.Group("/app/:appKey")
|
||||
{
|
||||
appGroupWithStatusCheck.Use(middleware.CheckAppStatus())
|
||||
appGroupWithStatusCheck.Use(app.AppCryptoMiddleware())
|
||||
appGroupWithStatusCheck.Use(app.ResponseEncryption())
|
||||
app.SetupRoutes(appGroupWithStatusCheck)
|
||||
app.SetupAuthUserRoutes(appGroupWithStatusCheck)
|
||||
app.SetupDevicePublicRoutes(appGroupWithStatusCheck)
|
||||
}
|
||||
|
||||
appAuthGroup := api.Group("/app/:appKey")
|
||||
{
|
||||
appAuthGroup.Use(middleware.JWT())
|
||||
appAuthGroup.Use(middleware.CheckAppStatus())
|
||||
appAuthGroup.Use(app.AppCryptoMiddleware())
|
||||
appAuthGroup.Use(app.ResponseEncryption())
|
||||
app.SetupCloudRoutes(appAuthGroup)
|
||||
app.SetupAuthRoutes(appAuthGroup)
|
||||
}
|
||||
|
||||
extGroup := api.Group("")
|
||||
{
|
||||
extension.SetupRoutes(extGroup)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user