Apply suggestions from code review

state-management
RW 2025-03-31 09:30:03 +02:00 committed by GitHub
parent a9c29b121c
commit a5c07b7c78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -543,8 +543,8 @@ func main() {
app.Get("/config", func(c fiber.Ctx) error { app.Get("/config", func(c fiber.Ctx) error {
config := map[string]any{ config := map[string]any{
"environment": environment, "environment": environment,
"apiUrl": fiber.GetStateWithDefault(app.State(), "apiUrl", ""), "apiUrl": fiber.GetStateWithDefault(c.App().State(), "apiUrl", ""),
"debug": fiber.GetStateWithDefault(app.State(), "debug", false), "debug": fiber.GetStateWithDefault(c.App().State(), "debug", false),
} }
return c.JSON(config) return c.JSON(config)
}) })
@ -601,7 +601,7 @@ func main() {
} }
// Save the user to the database. // Save the user to the database.
rdb, ok := fiber.GetState[*redis.Client](app.State(), "redis") rdb, ok := fiber.GetState[*redis.Client](c.App().State(), "redis")
if !ok { if !ok {
return c.Status(fiber.StatusInternalServerError).SendString("Redis client not found") return c.Status(fiber.StatusInternalServerError).SendString("Redis client not found")
} }
@ -619,7 +619,7 @@ func main() {
app.Get("/user/:id", func(c fiber.Ctx) error { app.Get("/user/:id", func(c fiber.Ctx) error {
id := c.Params("id") id := c.Params("id")
rdb, ok := fiber.GetState[*redis.Client](app.State(), "redis") rdb, ok := fiber.GetState[*redis.Client](c.App().State(), "redis")
if !ok { if !ok {
return c.Status(fiber.StatusInternalServerError).SendString("Redis client not found") return c.Status(fiber.StatusInternalServerError).SendString("Redis client not found")
} }