Skip to content

Commit 8bdaf79

Browse files
committed
fix test bugs & add dep vendor
1 parent f68ff00 commit 8bdaf79

File tree

5 files changed

+100
-17
lines changed

5 files changed

+100
-17
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea/
2+
vendor/

Gopkg.lock

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
24+
[[constraint]]
25+
name = "github.com/labstack/echo"
26+
version = "3.2.3"

pprof.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77
"github.com/labstack/echo"
88
)
99

10-
// Wrap adds several routes from package `net/http/pprof` to *echo.Echo object
10+
// Wrap adds several routes from package `net/http/pprof` to *echo.Echo object.
1111
func Wrap(e *echo.Echo) {
1212
WrapGroup("", e.Group(""))
1313
}
1414

15-
// Wrapper make sure we are backward compatible
15+
// Wrapper make sure we are backward compatible.
1616
var Wrapper = Wrap
1717

18-
// WrapGroup adds several routes from package `net/http/pprof` to *echo.Group object
18+
// WrapGroup adds several routes from package `net/http/pprof` to *echo.Group object.
1919
func WrapGroup(prefix string, g *echo.Group) {
2020
routers := []struct {
2121
Method string
@@ -45,79 +45,79 @@ func WrapGroup(prefix string, g *echo.Group) {
4545
}
4646
}
4747

48-
// IndexHandler will pass the call from /debug/pprof to pprof
48+
// IndexHandler will pass the call from /debug/pprof to pprof.
4949
func IndexHandler() echo.HandlerFunc {
5050
return func(ctx echo.Context) error {
5151
pprof.Index(ctx.Response().Writer, ctx.Request())
5252
return nil
5353
}
5454
}
5555

56-
// HeapHandler will pass the call from /debug/pprof/heap to pprof
56+
// HeapHandler will pass the call from /debug/pprof/heap to pprof.
5757
func HeapHandler() echo.HandlerFunc {
5858
return func(ctx echo.Context) error {
5959
pprof.Handler("heap").ServeHTTP(ctx.Response(), ctx.Request())
6060
return nil
6161
}
6262
}
6363

64-
// GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof
64+
// GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof.
6565
func GoroutineHandler() echo.HandlerFunc {
6666
return func(ctx echo.Context) error {
6767
pprof.Handler("goroutine").ServeHTTP(ctx.Response().Writer, ctx.Request())
6868
return nil
6969
}
7070
}
7171

72-
// BlockHandler will pass the call from /debug/pprof/block to pprof
72+
// BlockHandler will pass the call from /debug/pprof/block to pprof.
7373
func BlockHandler() echo.HandlerFunc {
7474
return func(ctx echo.Context) error {
7575
pprof.Handler("block").ServeHTTP(ctx.Response().Writer, ctx.Request())
7676
return nil
7777
}
7878
}
7979

80-
// ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof
80+
// ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof.
8181
func ThreadCreateHandler() echo.HandlerFunc {
8282
return func(ctx echo.Context) error {
8383
pprof.Handler("threadcreate").ServeHTTP(ctx.Response().Writer, ctx.Request())
8484
return nil
8585
}
8686
}
8787

88-
// CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof
88+
// CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof.
8989
func CmdlineHandler() echo.HandlerFunc {
9090
return func(ctx echo.Context) error {
9191
pprof.Cmdline(ctx.Response().Writer, ctx.Request())
9292
return nil
9393
}
9494
}
9595

96-
// ProfileHandler will pass the call from /debug/pprof/profile to pprof
96+
// ProfileHandler will pass the call from /debug/pprof/profile to pprof.
9797
func ProfileHandler() echo.HandlerFunc {
9898
return func(ctx echo.Context) error {
9999
pprof.Profile(ctx.Response().Writer, ctx.Request())
100100
return nil
101101
}
102102
}
103103

104-
// SymbolHandler will pass the call from /debug/pprof/symbol to pprof
104+
// SymbolHandler will pass the call from /debug/pprof/symbol to pprof.
105105
func SymbolHandler() echo.HandlerFunc {
106106
return func(ctx echo.Context) error {
107107
pprof.Symbol(ctx.Response().Writer, ctx.Request())
108108
return nil
109109
}
110110
}
111111

112-
// TraceHandler will pass the call from /debug/pprof/trace to pprof
112+
// TraceHandler will pass the call from /debug/pprof/trace to pprof.
113113
func TraceHandler() echo.HandlerFunc {
114114
return func(ctx echo.Context) error {
115115
pprof.Trace(ctx.Response().Writer, ctx.Request())
116116
return nil
117117
}
118118
}
119119

120-
// MutexHandler will pass the call from /debug/pprof/mutex to pprof
120+
// MutexHandler will pass the call from /debug/pprof/mutex to pprof.
121121
func MutexHandler() echo.HandlerFunc {
122122
return func(ctx echo.Context) error {
123123
pprof.Handler("mutex").ServeHTTP(ctx.Response().Writer, ctx.Request())

pprof_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func newServer() *echo.Echo {
1212
return e
1313
}
1414

15-
func checkRouters(routers []echo.Route, t *testing.T) {
15+
func checkRouters(routers []*echo.Route, t *testing.T) {
1616
expectedRouters := map[string]string{
1717
"/debug/pprof/": "IndexHandler",
1818
"/debug/pprof/heap": "HeapHandler",
@@ -34,8 +34,8 @@ func checkRouters(routers []echo.Route, t *testing.T) {
3434
if !ok {
3535
t.Errorf("missing router %s", router.Path)
3636
}
37-
if !strings.Contains(router.Handler, name) {
38-
t.Errorf("handler for %s should contain %s, got %s", router.Path, name, router.Handler)
37+
if !strings.Contains(router.Name, name) {
38+
t.Errorf("handler for %s should contain %s, got %s", router.Path, name, router.Name)
3939
}
4040
}
4141
}
@@ -50,7 +50,6 @@ func TestWrap(t *testing.T) {
5050
// go test github.com/sevenNt/echo-pprof -v -run=TestWrapGroup\$
5151
func TestWrapGroup(t *testing.T) {
5252
for _, prefix := range []string{"/debug"} {
53-
//for _, prefix := range []string{"/debug", "/debug/", "/debug/pprof", "/debug/pprof/"} {
5453
e := newServer()
5554
g := e.Group(prefix)
5655
WrapGroup(prefix, g)

0 commit comments

Comments
 (0)