httpprof

package module
v0.0.0-...-06ecd07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 3 Imported by: 0

README

给httprouter添加pprof

1:获取包

go get github.com/feixiao/httpprof

2:进入所在目录,获取依赖

 govendor sync

3:编译运行example

go build

4:外部项目添加使用,只需要参考example的使用即可

func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	fmt.Fprint(w, "Welcome!\n")
}

func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}

func main() {
	router := httprouter.New()

	// 在原来的httprouter的使用基础只是添加了这一句代码
	router = httpprof.WrapRouter(router)

	router.GET("/", Index)
	router.GET("/hello/:name", Hello)

	log.Fatal(http.ListenAndServe(":8080", router))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapRouter

func WrapRouter(r *httprouter.Router) *httprouter.Router

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL