-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🐛 [Bug]: Healthcheck middleware doesn't work with group #2860
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@ulasakdeniz What happens if you do this instead: group.Use("/livez", healthcheck.New()) |
https://github.com/gofiber/fiber/blob/v2/group.go#L62 https://github.com/gofiber/fiber/blob/v2/middleware/healthcheck/healthcheck.go#L13 @ReneWerner87 Is this a limitation, bug, or possible feature we need to add? |
@efectn Forgot to tag you :-) |
Hi @gaby thanks for your answer. That also doesn't work. Edit: My Go version: go version go1.21.4 darwin/amd64 |
|
@luk3skyw4lker can you help with a fix ? |
@ReneWerner87 sure! I can check it out today and try to send a PR with the fix |
@ReneWerner87 by what I've read right now the problem is that c.Path returns the full path (like /group/livez) and the check fails, so I should be reducing the c.Path to check if the last route is a /livez route. Is this right? |
right, that would be one solution, a second one is to check only the suffix of the route, but that would be a not quite perfect one |
https://github.com/gofiber/fiber/blob/main/router.go#L62 we should reduce it with the information of the current route |
@ReneWerner87 I could only think about splitting the Path and checking the suffix, but that would remove any possbility of having any /[n+]/(livez | readyz) routes. But I think this could be a problem in the future, right? |
someting like this but better switch c.Path()[len(c.Route().Path):] {
case cfg.ReadinessEndpoint:
return isReadyHandler(c)
case cfg.LivenessEndpoint:
return isLiveHandler(c)
} |
@ReneWerner87 yep, I'll check them and write a test with StrictRouting mode too. Thanks for the help and heads up! |
@ReneWerner87 I'll send a PR with the reports and results by Sunday, is that okay? |
Sure thx |
Bug Description
Hi, I have a problem with running healthcheck middleware with a group:
localhost:5001/app/livez
doesn't work:localhost:5001/app/hello
worksHow to Reproduce
Steps to reproduce the behavior:
Expected Behavior
The endpoint should return HTTP 200
Fiber Version
v2.52.0
Code Snippet (optional)
No response
Checklist:
The text was updated successfully, but these errors were encountered: