MXS-1220: Respond with 200 OK to root level requests

If a request to the `/` resource is made, the API responds with an 200
OK. This is done to make it possible to use the HTTP health check
mechanism found in many cloud load balancers.
This commit is contained in:
Markus Mäkelä
2017-05-06 10:05:59 +03:00
parent e3ff3b56bc
commit 3e1ff70d7d

View File

@ -104,7 +104,12 @@ int Client::process(string url, string method, const char* upload_data, size_t *
HttpRequest request(m_connection, url, method, json);
HttpResponse reply(MHD_HTTP_NOT_FOUND);
if (request.validate_api_version())
if (url == "/")
{
// Respond to pings with 200 OK
reply = HttpResponse(MHD_HTTP_OK);
}
else if (request.validate_api_version())
{
reply = resource_handle_request(request);
}