Fix and remove 14.6.md spaces
This commit is contained in:
54
zh/14.6.md
54
zh/14.6.md
@@ -14,39 +14,39 @@ runtime/pprof
|
||||
- 首先在beego.Run函数中根据变量是否自动加载性能包
|
||||
```Go
|
||||
|
||||
if PprofOn {
|
||||
BeeApp.RegisterController(`/debug/pprof`, &ProfController{})
|
||||
BeeApp.RegisterController(`/debug/pprof/:pp([\w]+)`, &ProfController{})
|
||||
}
|
||||
if PprofOn {
|
||||
BeeApp.RegisterController(`/debug/pprof`, &ProfController{})
|
||||
BeeApp.RegisterController(`/debug/pprof/:pp([\w]+)`, &ProfController{})
|
||||
}
|
||||
```
|
||||
- 设计ProfConterller
|
||||
```Go
|
||||
|
||||
package beego
|
||||
package beego
|
||||
|
||||
import (
|
||||
"net/http/pprof"
|
||||
)
|
||||
|
||||
type ProfController struct {
|
||||
Controller
|
||||
}
|
||||
|
||||
func (this *ProfController) Get() {
|
||||
switch this.Ctx.Params[":pp"] {
|
||||
default:
|
||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "":
|
||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "cmdline":
|
||||
pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "profile":
|
||||
pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "symbol":
|
||||
pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
}
|
||||
this.Ctx.ResponseWriter.WriteHeader(200)
|
||||
import (
|
||||
"net/http/pprof"
|
||||
)
|
||||
|
||||
type ProfController struct {
|
||||
Controller
|
||||
}
|
||||
|
||||
func (this *ProfController) Get() {
|
||||
switch this.Ctx.Params[":pp"] {
|
||||
default:
|
||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "":
|
||||
pprof.Index(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "cmdline":
|
||||
pprof.Cmdline(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "profile":
|
||||
pprof.Profile(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
case "symbol":
|
||||
pprof.Symbol(this.Ctx.ResponseWriter, this.Ctx.Request)
|
||||
}
|
||||
this.Ctx.ResponseWriter.WriteHeader(200)
|
||||
}
|
||||
|
||||
```
|
||||
## 使用入门
|
||||
|
||||
Reference in New Issue
Block a user