代码拉取完成,页面将自动刷新
package main
import (
"strings"
"team/common/web"
"team/config"
"team/controller"
"team/middleware"
rice "github.com/GeertJohan/go.rice"
_ "github.com/go-sql-driver/mysql"
)
func main() {
// Load configuration.
config.Load()
// Load resources.
resBox := rice.MustFindBox("view/dist")
mainPage := strings.ReplaceAll(resBox.MustString("app.html"), "__APP_NAME__", config.App.Name)
// Create router for httpd service.
router := web.NewRouter()
router.Use(middleware.Logger)
router.Use(middleware.PanicAsError)
// Statics.
router.SetPage("/", mainPage)
router.StaticFS("/assets", resBox.HTTPBox())
router.StaticFS("/uploads", web.Dir("uploads"))
// Home. Determine display mode.
router.GET("/home", controller.Home)
// Install/Login/Logout API.
router.UseController("/install", new(controller.Install), middleware.MustNotInstalled)
router.GET("/logout", controller.Logout, middleware.MustInstalled)
router.POST("/login", controller.Login, middleware.MustInstalled)
// Normal API.
api := router.Group("/api")
api.Use(middleware.MustInstalled)
api.Use(middleware.AutoLogin)
api.Use(middleware.MustLogined)
api.UseController("/user", new(controller.User))
api.UseController("/task", new(controller.Task))
api.UseController("/project", new(controller.Project))
api.UseController("/document", new(controller.Document))
api.UseController("/file", new(controller.File))
api.UseController("/notice", new(controller.Notice))
// Admin API.
router.UseController(
"/admin",
new(controller.Admin),
middleware.MustInstalled,
middleware.AutoLogin,
middleware.MustLoginedAsAdmin)
// Start service.
router.Start(config.App.Addr())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。