一、項目入口文件cmd.go
1.1 簡介:cmd層負(fù)責(zé)引導(dǎo)程序啟動,顯著的工作是初始化邏輯、注冊路由對象、啟動server監(jiān)聽、阻塞運行程序直至server退出。
1.2?代碼分析:
1.2.1?前臺系統(tǒng)路由注冊:
s.Group("/",func(group*ghttp.RouterGroup) {
group.Middleware(
service.Middleware().Ctx,
service.Middleware().ResponseHandler,
)
group.Bind(
controller.Index,//首頁
controller.Login,//登錄
controller.Register,//注冊
controller.Category,//欄目
controller.Topic,//主題
controller.Ask,//問答
controller.Article,//文章
controller.Reply,//回復(fù)
controller.Search,//搜索
controller.Captcha,//驗證碼
controller.User,//用戶
)
當(dāng)客戶端的請求