Skip to content

Replace API Debug Middleware #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025
Merged

Replace API Debug Middleware #631

merged 2 commits into from
Apr 30, 2025

Conversation

DanielCosme
Copy link
Contributor

@DanielCosme DanielCosme commented Nov 13, 2024

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.

Copy link
Member

@sevein sevein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just a couple of small requests.

@DanielCosme DanielCosme self-assigned this Apr 28, 2025
@DanielCosme DanielCosme merged commit eab5bda into main Apr 30, 2025
8 of 9 checks passed
@DanielCosme DanielCosme deleted the fix-api-debug branch April 30, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants