This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for #2300. See the issue for the issue details and initial investigation.
fixes #2300
The current sequence and tasks for each step are the following:
RequestLoggerFunc
pre-tasks (no condition)requester_id
request_id
request_id
RequestLoggerFunc
defer-tasks (no condition)PanicHandler
defer-tasks (when only panic happens)defaultErrorMiddleware
post-tasks (only when error returned)They are mostly orthogonal so the current order could be changed without side effects. Since step 5 sets the missing status for the response, moving step 3 next to step 5 can be the solution (the change of this PR).
The middleware stack will be fixed like:
As a result of this PR, the logs will be changed as the followings:
when the handler returns a non-nil error without the status code
become
See the
size
andstatus
in theINFO
log. The size represents the size of the error response set by the (default) error handler.for a similar situation but panic
become
as the same as above, the
INFO
line has the real size and status code.(In this case, pop middleware catch the panic by the recent fix gobuffalo/pop#775)
See the other cases related to this change
when the handler properly renders the result (same for 200, 404, 500,...):
when the app does not use pop middleware which catches the inner panic
This is the same as error situation.
still problematic (when the handler returns
nil
but the status code is still not set properly)See details in gobuffalo/buffalo-pop#19