mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:20:55 +00:00
Merge pull request #5 from corburn/master
Refactor pprof.go to use switch instead of if/else
This commit is contained in:
commit
8e90ddd577
14
pprof.go
14
pprof.go
@ -9,17 +9,17 @@ type ProfController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ProfController) Get() {
|
func (this *ProfController) Get() {
|
||||||
ptype := this.Ctx.Params[":pp"]
|
switch this.Ctx.Params[":pp"] {
|
||||||
if ptype == "" {
|
default:
|
||||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||||
} else if ptype == "cmdline" {
|
case "":
|
||||||
|
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||||
|
case "cmdline":
|
||||||
pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
|
pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||||
} else if ptype == "profile" {
|
case "profile":
|
||||||
pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
|
pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||||
} else if ptype == "symbol" {
|
case "symbol":
|
||||||
pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
|
pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||||
} else {
|
|
||||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
|
||||||
}
|
}
|
||||||
this.Ctx.ResponseWriter.WriteHeader(200)
|
this.Ctx.ResponseWriter.WriteHeader(200)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user