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

feature: HAR object endpoint for testing #834

Open
xinau opened this issue Sep 13, 2023 · 5 comments
Open

feature: HAR object endpoint for testing #834

xinau opened this issue Sep 13, 2023 · 5 comments

Comments

@xinau
Copy link

xinau commented Sep 13, 2023

I would like to use fortio for testing of an API gateway. It already provides a lot of the capabilities I desire, one feature that is/seems to be missing and would make automated testing easier, is an endpoint that returns the request as and HAR object similar to /debug. This endpoint could then be used for verifying that request modifications are as expected without requiring another tool like mockbin.

Is this something the fortio team would consider to be added? I'm also happy to provide a PR if wanted, just wanted to get a sense of the water (:

@ldemailly
Copy link
Member

I'm not personally familiar with HAR, what would it do to next level of details, is it just like a JSON version of debug? that could be an option/good idea for debug to take an param or react to Accept-Encoding:json ?

@xinau
Copy link
Author

xinau commented Sep 21, 2023

@ldemailly Hmm. my brain said I commented, obviously I didn't 😅. Sorry for the late reply then.

Exacly, HAR is just a specification on to turn a HTTP request into JSON. I'm not sure on how this is best exposed, like you mentioned I the following options exist

  1. Create a new endpoint /debug/har
  2. Use Accept: application/json under /debug
  3. Have a URL query parameter for the format, e.g. /debug?format=json

I don't have a strong preference here, I'm mostly leaning towards 2 or 1 then 3.

@xinau
Copy link
Author

xinau commented Sep 21, 2023

There appears to be a well maintained Go library for converting a http.Request into a HAR encoded JSON. Although, I'm not sure what Fortio's standpoint is on importing libraries, I would suggest at least checking it out and it's implementation. The library is also published under the Apache License 2.0.

@ldemailly
Copy link
Member

Thanks! (and again github fails to surface updates to issues, sorry)

@xinau
Copy link
Author

xinau commented Jan 10, 2024

@ldemailly any thoughts on how to move forward here. Happy to provide a PR the only two questions open to me are

  • Are you okay with pulling in another library or not?
  • Which method for exposing this do you prefer?

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