0c85c14e by Jason Travis

refactor: use switch instead of if/else to select ProfController type

1 parent aa4b66b9
Showing 1 changed file with 7 additions and 7 deletions
...@@ -9,17 +9,17 @@ type ProfController struct { ...@@ -9,17 +9,17 @@ type ProfController struct {
9 } 9 }
10 10
11 func (this *ProfController) Get() { 11 func (this *ProfController) Get() {
12 ptype := this.Ctx.Params[":pp"] 12 switch this.Ctx.Params[":pp"] {
13 if ptype == "" { 13 default:
14 pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request) 14 pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
15 } else if ptype == "cmdline" { 15 case "":
16 pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
17 case "cmdline":
16 pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request) 18 pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
17 } else if ptype == "profile" { 19 case "profile":
18 pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request) 20 pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
19 } else if ptype == "symbol" { 21 case "symbol":
20 pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request) 22 pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
21 } else {
22 pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
23 } 23 }
24 this.Ctx.ResponseWriter.WriteHeader(200) 24 this.Ctx.ResponseWriter.WriteHeader(200)
25 } 25 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!