Closed jvanrhyn closed 1 year ago
Using the below configuration
func StartAndServe() { logger := slog.Default() port := os.Getenv("PORT") slog.Info("Starting server on port", "port", port) app := fiber.New() group := app.Group("/api") group.Use(slogfiber.New(logger)) group.Get("/lookup/:ipaddress", getGeoInfo) err := app.Listen(":" + port) if err != nil { slog.Error("Error starting server", "error", err) } }
The call to getGeoInfo mapped above returns a simple 3 value JSON object
{ "city": "Johannesburg", "region": "Gauteng", "country": "South Africa" }
from the return call below.
return c.Status(fiber.StatusOK).JSON(lresp)
With group.Use(slogfiber.New(logger)) included the JSON is truncated from the response and nothing but OK is returned.
group.Use(slogfiber.New(logger))
OK
Below is the information logged by slogfiber.
2023-09-14T20:13:00.410576+02:00 INF Incoming request time="2023-09-14 20:13:00.410563 +0200 SAST" latency=94.375µs method=GET host=localhost:3000 path=/api/lookup/105.30.58.8 route=/api/lookup/:ipaddress status=200 ip=127.0.0.1 user-agent=insomnia/2023.5.8 referer="" request-id=717e4157-3f6e-4d86-a51c-92e1c7015786
I have forked the repository and implemented the change from pull request #5. This fixes the issue.
Using the below configuration
The call to getGeoInfo mapped above returns a simple 3 value JSON object
from the return call below.
With
group.Use(slogfiber.New(logger))
included the JSON is truncated from the response and nothing butOK
is returned.Below is the information logged by slogfiber.