Files
wx_service/internal/routes/routes.go
T
nepiedg cd7ae5ac56 Integrate Qiniu upload service and update configuration
- Added Qiniu configuration options to .env.example and config.go for file uploads.
- Refactored main.go to include new Qiniu service and upload handler.
- Updated route registration to accommodate the new upload handler.
- Enhanced documentation to include references for Qiniu upload functionality.
- Removed legacy authentication handler and services to streamline the codebase.
2025-12-31 03:18:03 +00:00

47 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package routes
import (
"net/http"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
authhandler "wx_service/internal/common/auth/handler"
commonhandler "wx_service/internal/common/handler"
"wx_service/internal/middleware"
rmhandler "wx_service/internal/remove_watermark/handler"
smokehandler "wx_service/internal/smoke/handler"
)
func Register(
router *gin.Engine,
db *gorm.DB,
authHandler *authhandler.AuthHandler,
videoHandler *rmhandler.VideoHandler,
smokeHandler *smokehandler.SmokeHandler,
uploadHandler *commonhandler.UploadHandler,
) {
// Register 用来集中注册所有 HTTP 路由,便于工程结构更清晰:
// - main 只负责初始化(配置/DB/依赖注入)
// - routes 只负责把 URL 映射到 handler
api := router.Group("/api/v1")
{
// 登录接口:用微信 code 换取/创建用户并返回 session_key(作为后续 Bearer Token
api.POST("/auth/login", authHandler.LoginWithWeChat)
// 需要登录的接口组:统一挂载鉴权中间件
protected := api.Group("")
protected.Use(middleware.AuthMiddleware(db))
{
registerCommonRoutes(protected, uploadHandler)
registerRemoveWatermarkRoutes(protected, videoHandler)
registerSmokeRoutes(protected, smokeHandler)
}
}
// 健康检查:用于容器/负载均衡探活
router.GET("/healthz", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "ok"})
})
}