Comments (17)
@ReneWerner87 sure! I can check it out today and try to send a PR with the fix
from fiber.
Sure thx
from fiber.
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
from fiber.
@ulasakdeniz What happens if you do this instead:
group.Use("/livez", healthcheck.New())
from fiber.
group.Use()
is expecting multiple params, and the middleware only returns a Fiber.Handler()
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?
from fiber.
@efectn Forgot to tag you :-)
from fiber.
@ulasakdeniz What happens if you do this instead:
group.Use("/livez", healthcheck.New())
Hi @gaby thanks for your answer. That also doesn't work.
Edit: My Go version: go version go1.21.4 darwin/amd64
from fiber.
from fiber.
@luk3skyw4lker can you help with a fix ?
from fiber.
@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?
from fiber.
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
from fiber.
https://github.com/gofiber/fiber/blob/main/router.go#L62
https://docs.gofiber.io/api/ctx#route
we should reduce it with the information of the current route
from fiber.
@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?
from fiber.
someting like this but better
switch c.Path()[len(c.Route().Path):] {
case cfg.ReadinessEndpoint:
return isReadyHandler(c)
case cfg.LivenessEndpoint:
return isLiveHandler(c)
}
from fiber.
func Test_HealthCheck_Group_Default(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Group("/v1", New())
v2 := app.Group("/v2/")
customer := v2.Group("/customer/")
customer.Use(New())
req, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/v1/readyz", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, req.StatusCode)
req, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/v1/livez", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, req.StatusCode)
req, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/v2/customer/readyz", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, req.StatusCode)
req, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/v2/customer/livez", nil))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, req.StatusCode)
}
prefixCount := len(utils.TrimRight(c.Route().Path, '/'))
if len(c.Path()) >= prefixCount {
switch c.Path()[prefixCount:] {
case cfg.ReadinessEndpoint:
return isReadyHandler(c)
case cfg.LivenessEndpoint:
return isLiveHandler(c)
}
}
can you make these adjustments and check them again
and also the benchmarks
perhaps we also need to test the strictRouting mode
and you find a better way to compare routes
from fiber.
@ReneWerner87 yep, I'll check them and write a test with StrictRouting mode too. Thanks for the help and heads up!
from fiber.
@ReneWerner87 I'll send a PR with the reports and results by Sunday, is that okay?
from fiber.
Related Issues (20)
- ๐ [v3 Proposal]: Koa Style `ctx.Request` and `ctx.Response` Objects HOT 12
- ๐ [Proposal]: Add options for active DisallowUnknownFields in the function BodyParser HOT 2
- ๐ [Bug]: Incorrect Parsing of Slice by `QueryParser()` with Embedded Structs HOT 2
- ๐ Doc: Fix code snippet indentation in /docs/api/middleware/keyauth.md HOT 4
- ๐ [Bug]: Isolation Issue with Parallel Subtests HOT 14
- ๐[Bug]: internal/storage/memory/memory_test HOT 1
- ๐ค [Question]: Validate request params HOT 5
- ๐ [v3 Proposal]: Refresh README.md HOT 2
- ๐ [v3 Proposal]: Improve more new features HOT 4
- ๐ [Bug]: (c *fiber.Ctx).ClearCookie() does absolutely nothing HOT 4
- ๐งน [v3 Maintenance]: Update docs to reflect fiber.Ctx struct to interface change HOT 1
- :bug: [BUG]: CORS panic with AcceptOrigins with whitespace HOT 1
- ๐งน [Maintenance]: Use Gotestsum for Test Workflow HOT 1
- ๐ค [Question]: Connect promhttp.Handler() to fiber app HOT 3
- ๐ [Bug]: Proxy middleware and Vite dev server on localhost, tcp4 127.0.0.1:5173: connect: connection refused HOT 6
- ๐ [Bug]: Enable go-require for testify-lint HOT 3
- ๐ค [Question]: When can the 3.0 version be applied to the production environment? HOT 3
- Explore Performance Optimization: Using a Pool for Memory Allocation in Client Package HOT 1
- Update Documentation and README.md for Client Package Refactor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.