Beego没gin配置静态页面方便
上代码
腾讯这个例子还是很值得学习的,不轻有东西,单也不重到看着都蒙圈的样子。
https://github.com/Tencent/bk-cmdb/blob/master/src/web_server/service/service.go
Beego没gin配置静态页面方便
下面是gin的静态页面承载配置。
ws.Static("/static", s.Config.Site.HtmlRoot) ws.LoadHTMLFiles(s.Config.Site.HtmlRoot + "/index.html")
简单吧。
func (s *Service) WebService() *gin.Engine { ws := gin.Default() ws.Use(sessions.Sessions(s.Config.Session.Name, s.Session)) ws.Use(middleware.ValidLogin(*s.Config, s.Discovery())) middleware.Engine = s.Engine ws.Static("/static", s.Config.Site.HtmlRoot) ws.LoadHTMLFiles(s.Config.Site.HtmlRoot + "/index.html") ws.POST("/hosts/import", s.ImportHost) ws.POST("/hosts/export", s.ExportHost) ws.POST("/importtemplate/:bk_obj_id", s.BuildDownLoadExcelTemplate) ws.POST("/insts/owner/:bk_supplier_account/object/:bk_obj_id/import", s.ImportInst) ws.POST("/insts/owner/:bk_supplier_account/object/:bk_obj_id/export", s.ExportInst) ws.POST("/logout", s.LogOutUser) ws.POST("/object/owner/:bk_supplier_account/object/:bk_obj_id/import", s.ImportObject) ws.POST("/object/owner/:bk_supplier_account/object/:bk_obj_id/export", s.ExportObject) ws.GET("/user/list", s.GetUserList) ws.GET("/user/language/:language", s.UpdateUserLanguage) ws.GET("/userinfo", s.UserInfo) ws.PUT("/user/current/supplier/:id", s.UpdateSupplier) ws.GET("/healthz", s.Healthz) ws.GET("/", s.Index) return ws }
网名:浩秦;
邮箱:root#landv.pw;
博客:landv.cnblogs.com;
只要我能控制一個國家的貨幣發行,我不在乎誰制定法律。金錢一旦作響,壞話隨之戛然而止。