From 3e1ff70d7d92bff016b7ea44a532be39ed0a390f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 6 May 2017 10:05:59 +0300 Subject: [PATCH] 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. --- server/core/admin.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/core/admin.cc b/server/core/admin.cc index 26ae490ea..7f2f4ca11 100644 --- a/server/core/admin.cc +++ b/server/core/admin.cc @@ -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); }