(c *cli.Context)
| 160 | } |
| 161 | |
| 162 | func runWeb(c *cli.Context) error { |
| 163 | err := route.GlobalInit(c.String("config")) |
| 164 | if err != nil { |
| 165 | log.Fatal("Failed to initialize application: %v", err) |
| 166 | } |
| 167 | |
| 168 | m := newMacaron() |
| 169 | |
| 170 | reqSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: true}) |
| 171 | ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: conf.Auth.RequireSigninView}) |
| 172 | reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true}) |
| 173 | |
| 174 | bindIgnErr := binding.BindIgnErr |
| 175 | |
| 176 | m.SetAutoHead(true) |
| 177 | |
| 178 | m.Group("", func() { |
| 179 | m.Get("/", ignSignIn, route.Home) |
| 180 | m.Group("/explore", func() { |
| 181 | m.Get("", func(c *context.Context) { |
| 182 | c.Redirect(conf.Server.Subpath + "/explore/repos") |
| 183 | }) |
| 184 | m.Get("/repos", route.ExploreRepos) |
| 185 | m.Get("/users", route.ExploreUsers) |
| 186 | m.Get("/organizations", route.ExploreOrganizations) |
| 187 | }, ignSignIn) |
| 188 | m.Combo("/install", route.InstallInit).Get(route.Install). |
| 189 | Post(bindIgnErr(form.Install{}), route.InstallPost) |
| 190 | m.Get("/^:type(issues|pulls)$", reqSignIn, user.Issues) |
| 191 | |
| 192 | // ***** START: User ***** |
| 193 | m.Group("/user", func() { |
| 194 | m.Group("/login", func() { |
| 195 | m.Combo("").Get(user.Login). |
| 196 | Post(bindIgnErr(form.SignIn{}), user.LoginPost) |
| 197 | m.Combo("/two_factor").Get(user.LoginTwoFactor).Post(user.LoginTwoFactorPost) |
| 198 | m.Combo("/two_factor_recovery_code").Get(user.LoginTwoFactorRecoveryCode).Post(user.LoginTwoFactorRecoveryCodePost) |
| 199 | }) |
| 200 | |
| 201 | m.Get("/sign_up", user.SignUp) |
| 202 | m.Post("/sign_up", bindIgnErr(form.Register{}), user.SignUpPost) |
| 203 | m.Get("/reset_password", user.ResetPasswd) |
| 204 | m.Post("/reset_password", user.ResetPasswdPost) |
| 205 | }, reqSignOut) |
| 206 | |
| 207 | m.Group("/user/settings", func() { |
| 208 | m.Get("", user.Settings) |
| 209 | m.Post("", bindIgnErr(form.UpdateProfile{}), user.SettingsPost) |
| 210 | m.Combo("/avatar").Get(user.SettingsAvatar). |
| 211 | Post(binding.MultipartForm(form.Avatar{}), user.SettingsAvatarPost) |
| 212 | m.Post("/avatar/delete", user.SettingsDeleteAvatar) |
| 213 | m.Combo("/email").Get(user.SettingsEmails). |
| 214 | Post(bindIgnErr(form.AddEmail{}), user.SettingsEmailPost) |
| 215 | m.Post("/email/delete", user.DeleteEmail) |
| 216 | m.Get("/password", user.SettingsPassword) |
| 217 | m.Post("/password", bindIgnErr(form.ChangePassword{}), user.SettingsPasswordPost) |
| 218 | m.Combo("/ssh").Get(user.SettingsSSHKeys). |
| 219 | Post(bindIgnErr(form.AddSSHKey{}), user.SettingsSSHKeysPost) |
nothing calls this directly
no test coverage detected