refactor: use switch instead of if/else to select ProfController type
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 | } | ... | ... |
-
Please register or sign in to post a comment