-
Notifications
You must be signed in to change notification settings - Fork 486
goss serve can now negotiate response's content-type via accept request header #609
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
goss serve can now negotiate response's content-type via accept request header #609
Conversation
dfad926
to
fb21491
Compare
fixes #318 (I wonder if this works as a comment) This looks great. Only question I have is whether we can cache the results rather than the rendered output? That can be a later improvement, since I think it will conflict with my big v4 refactor. What order should all these PR's be merged in? I'm planning to try to get them all merged this week. |
Yeah, I'd been thinking about that too. Yes we can. I've filed #612. re: order of merges - #586, #608, #606 are independent and can go first. I'll then rebase this one. I noticed https://probot.github.io/apps/dep/ which might allow this kind of maintainer-toil to be a bit easier? |
df5539b
to
21cfaa7
Compare
564ebbd
to
0a8e938
Compare
bcba2fb
to
43e8400
Compare
Got a chance to test this out today, I'm not sure if I'm misunderstanding the documentation or if there's a bug with the code. The following don't work and fallback on rspecish
Seems only JSON works? |
ab5ba0b
to
14c38fa
Compare
@aelsabbahy - you're not wrong 🤦 . Fixed in cf00396. |
Lol, all good. I tend to manually test most PRs just in case. Thanks for updating the tests as part of this. On my end I'm planning to:
Assuming both of those succeed, I'll merge this PR and probably cut a release. |
Tested this and it looks great. It's a little chatty (on the serve side) and I was wondering if that was intentional or leftover debug messages? |
@petemounce ping (only pinging you since I noticed you pushed out a change to the other PR) |
@aelsabbahy whoops, yes; those were debugs. I thought it was valuable to know when a response was coming from cache vs being calculated, so I left those in. I don't think it's particularly feasible to prefix the referer to ever log message at present using only the facilities of the |
Last one, is it intentional to have the test result in the log data of the serve command when test is failing? Here's what I see when a run fails with "documentation":
Here's a success:
|
Yes, that was intentional. When a test fails, without log output the options an operator has to debug it are to remote onto the machine and run it again. If the test fails intermittently, this will be harder to debug and reproduce. If it's time dependent, the operator may never be awake. Tests that are hard to debug, in my experience, are removed or worse, ignored, devaluing the other tests by association. |
Awesome work! Thank you for all the time and effort you've put into contributing to goss! |
My pleasure, thanks for merging :) |
Checklist
make test-all
(UNIX) passes. CI will also test thisDescription of change
Fixes #615.
goss serve
will now respond to theAccept
http header on incoming requests, and choose theContent-Type
for the response if possible based on that.This allows
goss serve
more flexibility at run-time; previously, if more than one output format was wanted, one endpoint process+port per output format would need to be set up.This PR builds on top of #606 and #608, and is aimed at allowing a single
goss serve
to satisfy both ofhttp://{host}:{port}/metrics
)This could be extended so that the response content-type can be driven from a querystring variable as well as a header, so it's more accessible to people in browsers compared to
curl
and machines.