mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 22:46:38 +08:00
docs(skill): update router packaging and categorization guidelines in documentation
- Updated `new-api` skill `SKILL.md` to document the centralized v1.go route registration and domain-driven sub-routing patterns - Updated `AGENTS.md` instructions with the new router subpackages (`root`, `v1`) and route file layout guidelines
This commit is contained in:
@@ -6,6 +6,7 @@ package root
|
||||
import (
|
||||
_ "github.com/Rain-kl/Wavelet/docs" // Swagger documentation generation setup
|
||||
publicconfig "github.com/Rain-kl/Wavelet/internal/apps/config"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/health"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/upload"
|
||||
"github.com/Rain-kl/Wavelet/internal/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -25,4 +26,7 @@ func RegisterDefaultRootRoutes(r *gin.Engine) {
|
||||
if !config.Config.App.IsProduction() {
|
||||
r.GET(config.Config.App.APIPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
}
|
||||
|
||||
// 4. Health check
|
||||
r.GET(config.Config.App.APIPrefix+"/health", health.Health)
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package v1 contains router registrations for API V1
|
||||
package v1
|
||||
|
||||
import (
|
||||
capApp "github.com/Rain-kl/Wavelet/internal/apps/cap"
|
||||
publicconfig "github.com/Rain-kl/Wavelet/internal/apps/config"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/health"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RegisterPublicRoutes registers all public routes (captcha, health, config).
|
||||
func RegisterPublicRoutes(apiV1Router *gin.RouterGroup, apiGroup *gin.RouterGroup) {
|
||||
// CAPTCHA
|
||||
registerCaptchaRoutes(apiGroup)
|
||||
|
||||
// Health
|
||||
apiGroup.GET("/health", health.Health)
|
||||
|
||||
// Config (public)
|
||||
registerConfigRoutes(apiV1Router)
|
||||
}
|
||||
|
||||
func registerCaptchaRoutes(apiGroup *gin.RouterGroup) {
|
||||
capGroup := apiGroup.Group("/cap")
|
||||
{
|
||||
capGroup.POST("/challenge", capApp.Challenge)
|
||||
capGroup.POST("/redeem", capApp.Redeem)
|
||||
}
|
||||
}
|
||||
|
||||
func registerConfigRoutes(apiV1Router *gin.RouterGroup) {
|
||||
configRouter := apiV1Router.Group("/config")
|
||||
{
|
||||
configRouter.GET("/public", publicconfig.GetPublicConfig)
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
|
||||
capApp "github.com/Rain-kl/Wavelet/internal/apps/cap"
|
||||
publicconfig "github.com/Rain-kl/Wavelet/internal/apps/config"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/upload"
|
||||
"github.com/Rain-kl/Wavelet/internal/apps/user"
|
||||
@@ -15,18 +16,39 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// RegisterUserRoutes registers all user-related, oauth and upload routes.
|
||||
func RegisterUserRoutes(apiV1Router *gin.RouterGroup) {
|
||||
// OAuth
|
||||
// RegisterUserRoutes registers all user-related, oauth, upload, and public routes.
|
||||
func RegisterUserRoutes(apiV1Router *gin.RouterGroup, apiGroup *gin.RouterGroup) {
|
||||
// 1. CAPTCHA
|
||||
registerCaptchaRoutes(apiGroup)
|
||||
|
||||
// 2. Config (public)
|
||||
registerConfigRoutes(apiV1Router)
|
||||
|
||||
// 3. OAuth
|
||||
registerOAuthRoutes(apiV1Router)
|
||||
|
||||
// User
|
||||
// 4. User
|
||||
registerUserRoutes(apiV1Router)
|
||||
|
||||
// Upload
|
||||
// 5. Upload
|
||||
registerUploadRoutes(apiV1Router)
|
||||
}
|
||||
|
||||
func registerCaptchaRoutes(apiGroup *gin.RouterGroup) {
|
||||
capGroup := apiGroup.Group("/cap")
|
||||
{
|
||||
capGroup.POST("/challenge", capApp.Challenge)
|
||||
capGroup.POST("/redeem", capApp.Redeem)
|
||||
}
|
||||
}
|
||||
|
||||
func registerConfigRoutes(apiV1Router *gin.RouterGroup) {
|
||||
configRouter := apiV1Router.Group("/config")
|
||||
{
|
||||
configRouter.GET("/public", publicconfig.GetPublicConfig)
|
||||
}
|
||||
}
|
||||
|
||||
func registerOAuthRoutes(apiV1Router *gin.RouterGroup) {
|
||||
apiV1Router.GET("/oauth/sources", oauth.GetLoginSources)
|
||||
apiV1Router.GET("/oauth/login", oauth.GetLoginURL)
|
||||
|
||||
@@ -10,15 +10,12 @@ import (
|
||||
|
||||
// RegisterV1Routes registers all routes under API V1.
|
||||
func RegisterV1Routes(apiV1Router *gin.RouterGroup, apiGroup *gin.RouterGroup) {
|
||||
// 1. Public (captcha, health, config)
|
||||
RegisterPublicRoutes(apiV1Router, apiGroup)
|
||||
// 1. User & Public routes (OAuth, User, Upload, CAPTCHA, Health, Config)
|
||||
RegisterUserRoutes(apiV1Router, apiGroup)
|
||||
|
||||
// 2. OAuth, User, Upload
|
||||
RegisterUserRoutes(apiV1Router)
|
||||
|
||||
// 3. Admin
|
||||
// 2. Admin routes
|
||||
RegisterAdminRoutes(apiV1Router)
|
||||
|
||||
// 4. Register custom business routes
|
||||
// 3. Register custom business routes
|
||||
RegisterCustomRoutes(apiV1Router)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user