Skip to content
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

Add optional flag in generation process to add the following http2curl call after every request. #3606

Open
wbatwb opened this issue Oct 25, 2024 · 1 comment

Comments

@wbatwb
Copy link

wbatwb commented Oct 25, 2024

Hello! As part of how I run things in my team, I like to have the option to enable a debug output that spits curl calls for every request out to the standard output of the machine. Here's an example of what this looks like. It would be quite simple to add this to the code generation process, and would even be a great option for somebody new to Open Source to complete.

The specification I suggest is the following.

Some mechanism for generating with http2curl should change a generation in goa to the following

  1. add http2curl as a dependency if there is a request in the file. Replace any request generation with the following workflow
  2. Add http2curl before the request
  3. Add http2curl after the request

its not clear which of the above would be better.

But I think this would be awesome because:

  1. it's optional.
  2. it doesn't initially sound too difficult to achieve.
  3. For our use case, lets us export and debug beginning with the http request for failures since postman lets you import curl.
  4. http2curl is just a couple lines so this is not something you need any other development for

command, _ := http2curl.GetCurlCommand(req) fmt.Println(command) //Send Request right before or after any instance of response, err := http.Client.Do(req)

@raphael
Copy link
Member

raphael commented Oct 29, 2024

Hello, this can be done by wrapping the HTTP client roundtripper similarly to how the clue log package does it to log client side requests and responses. Using this approach makes it possible add configuration option in particular for the formatting and output of the commands.

Alternatively it should be fairly simple to write a plugin that does exactly what is being suggested.

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

No branches or pull requests

2 participants