-
Notifications
You must be signed in to change notification settings - Fork 8
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 Request: support empty GET request. #31
Comments
Totally understand wanting health checking to be as simple as possible - shorter's better! Even without built-in GET support, I think you can shorten your k8s and Docker compose configurations a fair bit.
func ok(_ http.ResponseWriter, _ *http.Request) {}
func main() {
mux := http.NewServeMux()
// mount any other RPC handlers here, and then...
mux.Handle("/health", http.HandlerFunc(ok))
http.ListenAndServe(":8080", mux)
} |
Checked the code and found that if we want to be compatible with http GET, then the changes are significant. I agree with @akshayjshah that you can make simplifications in the application code. And the connect-go core lib is still simple. |
It would be nice to be able to hit the Check endpoint in the browser and it just work. |
This repo's purpose is to provide an implementation of the Wrapping a // HealthEndpoint returns a handler that responds with 200 if the requested
// service is okay and "503 Service Unavailable" otherwise. The service is
// indicated via "service" query parameter. If it is absent, the checker is
// queried with an empty service name. If the checker returns an error
// instead of a status, the result will be "500 Internal Server Error".
func HealthEndpoint(checker grpchealth.Checker) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
resp, err := checker.Check(r.Context(), &grpchealth.CheckRequest{
Service: r.URL.Query().Get("service"),
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if resp.Status != grpchealth.StatusServing {
w.WriteHeader(http.StatusServiceUnavailable)
} // else, 200 OK status is implied
})
} But, given the purpose of this repo, that is not really in scope for exported API provided by this module. |
grpchealth as is provides a pretty convenient up check that could be used for checking whether a server is running. This is pretty useful for kube or docker compose.
Right now, the "minimal" request needed looks like...
It would be nice if minimality could be brought down to...
NOTE: Setting
-X GET
causes405 Method Not Allowed
Removing the body and content-type causes
415 Unsupported Media Type
The text was updated successfully, but these errors were encountered: