-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix zero's health endpoint to return json response #8858
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM a few minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write some tests for it? Otherwise looks great.
32950b9
to
3e25acd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a few minor comments. Please print the error message in a separate Go code and make sure they look okay in the logs and make sense.
3e25acd
to
9d57a29
Compare
77ed794
to
f554eb9
Compare
aebb829
to
ee76626
Compare
Fixes #5517 Zero's /health endpoint just returns OK unlike Alpha's JSON output. ## Problem curl http://alpha-hostname:alpha-http-port/health returns a JSON output whereas, curl http://zero-hostname:zero-http-port/health returns a plain text "OK". ## Solution Added code to return a plain text output ("OK") for the "text/plain" to maintain the backward compatibility and return JSON output for "Accept: application/json" header. Example Output: $ curl http://localhost:58696/health OK $ curl -H "Accept: application/json" http://localhost:58696/health {"instance":"zero","address":"zero1:5080","status":"healthy","version":"v23.0.0-16-g90139243f","uptime":9223372036,"lastEcho":1686137664}
Fixes #5517 Zero's /health endpoint just returns OK unlike Alpha's JSON output.
Problem
curl http://alpha-hostname:alpha-http-port/health returns a JSON output whereas, curl http://zero-hostname:zero-http-port/health returns a plain text "OK".
Solution
Added code to return a plain text output ("OK") for the "text/plain" to maintain the backward compatibility and return JSON output for "Accept: application/json" header.
Example Output:
$ curl http://localhost:58696/health
OK
$ curl -H "Accept: application/json" http://localhost:58696/health
{"instance":"zero","address":"zero1:5080","status":"healthy","version":"v23.0.0-16-g90139243f","uptime":9223372036,"lastEcho":1686137664}