Replace API Debug Middleware #631
Merged
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 MR tries to address a problem when using Enduro with the API in Debug mode.
The Debug middle-ware prints to stdout details about the request, including the bodies of both the request and response. This is usually what we want, except when we are downloading binary files (like compressed AIPs), when the Download package endpoint is hit with download request, the Download fails (if debug = true) while the payload is printed (a binary blob) to stdout. In this usecase the download fails (bytes get dropped consistently).
To solve this issue I decided to avoid printing the response body when the
Content-Type
is of:application/x-7z-compressed
. Since the Debug middleware belongs to the Goa library I could not modify it, I decided to copy the exact middleware and modify only what I needed.So, this MR is almost a perfect copy of this file here: https://github.com/goadesign/goa/blob/v3/http/middleware/debug.go
With the difference that we just avoid printing the Body if the condition is meet.