diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-22 00:50:47 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-22 00:50:47 +0800 |
commit | 17da2fd2e30e85909394bc58069ecab14d8d8577 (patch) | |
tree | d80e786818d20aed12b7a84f6a9961468a7f70ec /web.go | |
parent | efdaf6ee1536f043d9e242dc16a096c99ec1bfda (diff) | |
parent | f219ddcf4ef13b9d5de129da4eb2b56dbc899d61 (diff) | |
download | gitea-17da2fd2e30e85909394bc58069ecab14d8d8577.tar.gz gitea-17da2fd2e30e85909394bc58069ecab14d8d8577.zip |
merged
Diffstat (limited to 'web.go')
-rw-r--r-- | web.go | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -16,11 +16,14 @@ import ( "github.com/gogits/binding" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/routers" + "github.com/gogits/gogs/routers/admin" "github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/user" @@ -35,6 +38,16 @@ gogs web`, Flags: []cli.Flag{}, } +// globalInit is for global configuration reload-able. +func globalInit() { + base.NewConfigContext() + mailer.NewMailerContext() + models.LoadModelsConfig() + models.LoadRepoConfig() + models.NewRepoContext() + models.NewEngine() +} + // Check run mode(Default of martini is Dev). func checkRunMode() { switch base.Cfg.MustValue("", "RUN_MODE") { @@ -58,6 +71,7 @@ func newMartini() *martini.ClassicMartini { } func runWeb(*cli.Context) { + globalInit() base.NewServices() checkRunMode() log.Info("%s %s", base.AppName, base.AppVer) @@ -73,7 +87,8 @@ func runWeb(*cli.Context) { m.Use(middleware.InitContext()) - reqSignIn, ignSignIn := middleware.SignInRequire(true), middleware.SignInRequire(false) + reqSignIn := middleware.SignInRequire(true) + ignSignIn := middleware.SignInRequire(base.Service.RequireSignInView) reqSignOut := middleware.SignOutRequire() // Routers. m.Get("/", ignSignIn, routers.Home) @@ -99,6 +114,14 @@ func runWeb(*cli.Context) { m.Get("/help", routers.Help) + adminReq := middleware.AdminRequire() + m.Get("/admin", reqSignIn, adminReq, admin.Dashboard) + m.Get("/admin/users", reqSignIn, adminReq, admin.Users) + m.Any("/admin/users/new", reqSignIn, adminReq, binding.BindIgnErr(auth.RegisterForm{}), admin.NewUser) + m.Any("/admin/users/:userid", reqSignIn, adminReq, binding.BindIgnErr(auth.AdminEditUserForm{}), admin.EditUser) + m.Get("/admin/repos", reqSignIn, adminReq, admin.Repositories) + m.Get("/admin/config", reqSignIn, adminReq, admin.Config) + m.Post("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.SettingPost) m.Get("/:username/:reponame/settings", reqSignIn, middleware.RepoAssignment(true), repo.Setting) |