Closed samber closed 5 months ago
Attention: 147 lines
in your changes are missing coverage. Please review.
Comparison is base (
38a183c
) 0.00% compared to head (bfa4885
) 0.00%.
Files | Patch % | Lines |
---|---|---|
middleware.go | 0.00% | 87 Missing :warning: |
error-handler.go | 0.00% | 39 Missing :warning: |
config.go | 0.00% | 15 Missing :warning: |
deprecated.go | 0.00% | 6 Missing :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Sorry, it took me a bit longer to check on this.
The Error handler works and now all the context attributes I set do show up in the log line. That's great.
However, there's still two issues:
status=
in the log line still reports 200
on a 404
return fmt.Errorf("some error")
, I also still get status=200
and the same happens with a fiber.NewError()
callfiber.Error.Code
Also, for requests that are found, this no longer logs anything (since the error handler never executes). That makes sense, but it makes me wonder why there's the "error handler is now preferred" in the README since it seems like you would need both?
I'm really puzzled by the status thing since that's definitely not slogfiber messing it up. It's just the value on ctx.Response().StatusCode()
which I really don't expect to be a 200 if we're in the error handler. My guess is that in the error handler this has to be explicitly extracted from the err
passed to it, instead of using c.Response().StatusCode()
since the error handler is expected to write the reply on the wire.
I think so, we should handle an error like that
status := c.Response().StatusCode()
var e *fiber.Error
if errors.As(err, &e) {
status = e.Code
}
Closing in favor of #19
This PR allows to move the logger into *fiber.ErrorHandler:
Use either:
NewXXX
constructors have been renamed toNewMiddlewareXXX
. Previous functions are marked as deprecated.Via error handler
Via middleware