MCPcopy
hub / github.com/gofiber/fiber / getEffectiveStatusCode

Function getEffectiveStatusCode

middleware/limiter/limiter.go:33–46  ·  view source on GitHub ↗

getEffectiveStatusCode returns the actual status code, considering both the error and response status

(c fiber.Ctx, err error)

Source from the content-addressed store, hash-verified

31
32// getEffectiveStatusCode returns the actual status code, considering both the error and response status
33func getEffectiveStatusCode(c fiber.Ctx, err error) int {
34 if nilerror.IsNil(err) {
35 return c.Response().StatusCode()
36 }
37
38 // If there's an error and it's a *fiber.Error, use its status code
39 var fiberErr *fiber.Error
40 if errors.As(err, &fiberErr) && fiberErr != nil {
41 return fiberErr.Code
42 }
43
44 // Otherwise, use the response status code
45 return c.Response().StatusCode()
46}

Calls 3

IsNilFunction · 0.92
ResponseMethod · 0.65
StatusCodeMethod · 0.45