Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recipe: add pprof example 🔥 #7

Closed
mthli opened this issue Apr 12, 2020 · 2 comments
Closed

recipe: add pprof example 🔥 #7

mthli opened this issue Apr 12, 2020 · 2 comments
Labels
✏️ Feature New feature or request

Comments

@mthli
Copy link

mthli commented Apr 12, 2020

Is your feature request related to a problem?

Yes, but not fiber's problem, I think.

Describe the solution you'd like

I want to debug my Go project with net/http/pprof , so I writed a code snippet as below.

And I think it could be a recipe of fiber 😄

package main

import (
	"github.com/gofiber/fiber"
	"github.com/valyala/fasthttp/pprofhandler"
)

func main() {
	// Create new Fiber instance
	app := fiber.New()

	// Create new group route on path "/debug/pprof"
	app.Group("/debug/pprof", func(c *fiber.Ctx) {
		pprofhandler.PprofHandler(c.Fasthttp)
	})

	// Start server on http://localhost:3000
	app.Listen(3000)
}

If you visit http://localhost:3000/debug/pprof/ , everything is ok.

But if you visit http://localhost:3000/debug/pprof , the right subpath like http://localhost:3000/debug/pprof/goroutine will be replaced with the wrong subpath http://localhost:3000/debug/goroutine , so you will get nothing but 404.

Describe alternatives you've considered

It's because of pprof's template depends on the last / to separate different subpaths, so you should always visit http://localhost:3000/debug/pprof/ 😄

Additional context

Always use Safari to visit http://localhost:3000/debug/pprof to get 404.

@mthli mthli added the ✏️ Feature New feature or request label Apr 12, 2020
@welcome
Copy link

welcome bot commented Apr 12, 2020

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!

@Fenny
Copy link
Member

Fenny commented Apr 12, 2020

@Fenny Fenny closed this as completed Apr 12, 2020
This was referenced Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants