新增注释

This commit is contained in:
2026-05-09 17:50:40 +08:00
parent d5c053e59d
commit 8504838ccb
19 changed files with 404 additions and 217 deletions
+4 -1
View File
@@ -5,10 +5,13 @@ import (
"level_go/internal/api"
)
// NewRouter 创建并配置 API 路由。
//
// 函数集中注册跨域中间件和 v1 版本接口,调用方只需要注入各业务 Handler。
func NewRouter(commonApi *api.CommonHandler, stockApi *api.StockHandler, limitBoardApi *api.LimitBoardHandler) *gin.Engine {
r := gin.Default()
// 跨域中间件 (根据需要开启)
// 跨域中间件允许前端从任意来源访问接口,并暴露 CSV 下载需要的 Content-Disposition。
r.Use(func(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS")