8e90ddd5 by astaxie

Merge pull request #5 from corburn/master

Refactor pprof.go to use switch instead of if/else
2 parents aa4b66b9 0c85c14e
Showing 1 changed file with 7 additions and 7 deletions
......@@ -9,17 +9,17 @@ type ProfController struct {
}
func (this *ProfController) Get() {
ptype := this.Ctx.Params[":pp"]
if ptype == "" {
switch this.Ctx.Params[":pp"] {
default:
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)
} else if ptype == "profile" {
case "profile":
pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
} else if ptype == "symbol" {
case "symbol":
pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
} else {
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
}
this.Ctx.ResponseWriter.WriteHeader(200)
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!