mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 00:56:37 +08:00
refactor(router): organize root routes and centralize v1 route registration
- Created `internal/router/root` package to register root-level paths - Moved files serving, robots.txt, and Swagger docs to `root/default.go` - Registered custom root routes under `root/custom.go` - Centralized all v1 routes registration in `internal/router/v1/v1.go` - Simplified `internal/router/router.go` by delegating route registration - Updated `new-api` skill `SKILL.md` to document the new router structure
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
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/upload"
|
||||
"github.com/Rain-kl/Wavelet/internal/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
)
|
||||
|
||||
// RegisterDefaultRootRoutes registers default routes that belong to the root path.
|
||||
func RegisterDefaultRootRoutes(r *gin.Engine) {
|
||||
// 1. Serve files by ID
|
||||
r.GET("/f/:id", upload.ServeFileByID)
|
||||
|
||||
// 2. Dynamic robots.txt serving
|
||||
r.GET("/robots.txt", publicconfig.GetRobotsTXT)
|
||||
|
||||
// 3. Swagger routes (Non-production only)
|
||||
if !config.Config.App.IsProduction() {
|
||||
r.GET(config.Config.App.APIPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user