Files
GoCode/main.go
nannanwu b7b0c32e82 feat(router): 添加管理员路由中间件支持
- 在admin路由组中集成InitMiddleware中间件
- middleware包新增InitMiddleware实现用户身份设置与请求日志打印
- 管理员控制器Index方法增加从上下文获取用户名的逻辑并打印
- 主程序中初始化admin、api和default路由
- 修正default路由初始化时的代码格式问题
2026-02-22 13:42:58 +08:00

32 lines
590 B
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 main
import (
"awesomeProject/router"
"github.com/gin-gonic/gin"
)
// main 函数是程序的入口点初始化并启动Web服务器
func main() {
// 创建默认的gin引擎
r := gin.Default()
// 加载模板文件,支持多层目录结构
r.LoadHTMLGlob("templates/**/*")
// 配置静态文件目录,将./static目录映射到URL路径/static
r.Static("/static", "./static")
router.AdminRouterInit(r)
router.ApiRouterInit(r)
router.DefaultRouterInit(r)
// 启动HTTP服务器监听在8081端口
err := r.Run(":8088")
if err != nil {
return
}
}