Browse Source

Move debug router location

pull/283/head
Unknown 10 years ago
parent
commit
7ffdabb28f
  1. 1
      .gitignore
  2. 4
      cmd/web.go
  3. 5
      models/issue.go
  4. 11
      routers/debug/ignored.go
  5. 8
      routers/dev/debug.go

1
.gitignore vendored

@ -12,7 +12,6 @@ public/img/avatar/
*.o *.o
*.a *.a
*.so *.so
dev
# Folders # Folders
_obj _obj

4
cmd/web.go

@ -26,7 +26,6 @@ import (
"github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers"
"github.com/gogits/gogs/routers/admin" "github.com/gogits/gogs/routers/admin"
"github.com/gogits/gogs/routers/api/v1" "github.com/gogits/gogs/routers/api/v1"
"github.com/gogits/gogs/routers/debug"
"github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/dev"
"github.com/gogits/gogs/routers/org" "github.com/gogits/gogs/routers/org"
"github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/repo"
@ -185,6 +184,7 @@ func runWeb(*cli.Context) {
if martini.Env == martini.Dev { if martini.Env == martini.Dev {
m.Get("/template/**", dev.TemplatePreview) m.Get("/template/**", dev.TemplatePreview)
dev.RegisterDebugRoutes(m)
} }
reqTrueOwner := middleware.RequireTrueOwner() reqTrueOwner := middleware.RequireTrueOwner()
@ -206,8 +206,6 @@ func runWeb(*cli.Context) {
r.Post("/:org/settings/delete", org.DeletePost) r.Post("/:org/settings/delete", org.DeletePost)
}, reqSignIn) }, reqSignIn)
debug.RegisterRoutes(m)
m.Group("/:username/:reponame", func(r martini.Router) { m.Group("/:username/:reponame", func(r martini.Router) {
r.Get("/settings", repo.Setting) r.Get("/settings", repo.Setting)
r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost) r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost)

5
models/issue.go

@ -276,6 +276,10 @@ func GetIssueUserPairs(rid, uid int64, isClosed bool) ([]*IssueUser, error) {
// GetIssueUserPairsByRepoIds returns issue-user pairs by given repository IDs. // GetIssueUserPairsByRepoIds returns issue-user pairs by given repository IDs.
func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*IssueUser, error) { func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*IssueUser, error) {
if len(rids) == 0 {
return []*IssueUser{}, nil
}
buf := bytes.NewBufferString("") buf := bytes.NewBufferString("")
for _, rid := range rids { for _, rid := range rids {
buf.WriteString("repo_id=") buf.WriteString("repo_id=")
@ -283,7 +287,6 @@ func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*Issue
buf.WriteString(" OR ") buf.WriteString(" OR ")
} }
cond := strings.TrimSuffix(buf.String(), " OR ") cond := strings.TrimSuffix(buf.String(), " OR ")
ius := make([]*IssueUser, 0, 10) ius := make([]*IssueUser, 0, 10)
sess := x.Limit(20, (page-1)*20).Where("is_closed=?", isClosed) sess := x.Limit(20, (page-1)*20).Where("is_closed=?", isClosed)
if len(cond) > 0 { if len(cond) > 0 {

11
routers/debug/ignored.go

@ -1,11 +0,0 @@
// +build !pprof
package debug
import (
"github.com/go-martini/martini"
)
func RegisterRoutes(r martini.Router) {
// do nothing
}

8
routers/debug/debug.go → routers/dev/debug.go

@ -1,6 +1,8 @@
// +build pprof // Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package debug package dev
import ( import (
"net/http/pprof" "net/http/pprof"
@ -8,7 +10,7 @@ import (
"github.com/go-martini/martini" "github.com/go-martini/martini"
) )
func RegisterRoutes(r martini.Router) { func RegisterDebugRoutes(r martini.Router) {
r.Any("/debug/pprof/cmdline", pprof.Cmdline) r.Any("/debug/pprof/cmdline", pprof.Cmdline)
r.Any("/debug/pprof/profile", pprof.Profile) r.Any("/debug/pprof/profile", pprof.Profile)
r.Any("/debug/pprof/symbol", pprof.Symbol) r.Any("/debug/pprof/symbol", pprof.Symbol)
Loading…
Cancel
Save