Skip to content

Remove redudant CheckUnit calls in router #2627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func RegisterRoutes(m *macaron.Macaron) {
// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.
// So they can apply their own enable/disable logic on routers.
m.Group("/issues", func() {
m.Combo("/new", repo.MustEnableIssues).Get(context.RepoRef(), repo.NewIssue).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems no replacement for this removal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handler in parent func, line 509, use context.CheckUnit(models.UnitTypeIssues)

m.Combo("/new").Get(context.RepoRef(), repo.NewIssue).
Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost)

m.Group("/:index", func() {
Expand Down Expand Up @@ -606,12 +606,12 @@ func RegisterRoutes(m *macaron.Macaron) {
Post(bindIgnErr(auth.NewUncycloForm{}), repo.EditUncycloPost)
m.Post("/:page/delete", repo.DeleteUncycloPagePost)
}, reqSignIn, reqRepoWriter)
}, repo.MustEnableUncyclo, context.RepoRef(), context.CheckUnit(models.UnitTypeUncyclo))
}, repo.MustEnableUncyclo, context.RepoRef())

m.Group("/wiki", func() {
m.Get("/raw/*", repo.UncycloRaw)
m.Get("/*", repo.UncycloRaw)
}, repo.MustEnableUncyclo, context.CheckUnit(models.UnitTypeUncyclo), context.CheckUnit(models.UnitTypeUncyclo))
}, repo.MustEnableUncyclo)

m.Get("/archive/*", repo.MustBeNotBare, context.CheckUnit(models.UnitTypeCode), repo.Download)

Expand All @@ -620,7 +620,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/files", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.ViewPullFiles)
m.Post("/merge", reqRepoWriter, repo.MergePullRequest)
m.Post("/cleanup", context.RepoRef(), repo.CleanUpPullRequest)
}, repo.MustAllowPulls, context.CheckUnit(models.UnitTypePullRequests))
}, repo.MustAllowPulls)

m.Group("", func() {
m.Get("/raw/*", repo.SingleDownload)
Expand Down