For the status code to be correctly captured by the c.Response().StatusCode(),
the response must be dispatched to the client first.
To do this, we need to call the ErrorHandler right after c.Next() in the middleware.
By analyzing standard fiber logging middleware, we can see this.
For the status code to be correctly captured by the c.Response().StatusCode(), the response must be dispatched to the client first. To do this, we need to call the ErrorHandler right after c.Next() in the middleware. By analyzing standard fiber logging middleware, we can see this.
Using the same code of #18 for testing
Test 1: Get / (Expected: 200 | Received: 200)
Test 2: Post / (Expected: 405 | Received: 405)
Test 3: Post /bad (Expected: 400 | Received: 400)
Test 4: Get /die (Expected: 500 | Received: 500)
Test 5: Post /force (Expected: 401 | Received: 401)
Test 6: Get /notfound (Expected: 404 | Received: 404)
For this control to happen through the ErrorHandler, if desired, the catch-all function must not exist.