1 Star 0 Fork 138

风的旋轮/Team

forked from leo/Team
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
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())
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/fengdexuanlun/Team.git
[email protected]:fengdexuanlun/Team.git
fengdexuanlun
Team
Team
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385